make sure its a file not a folder
chown -R user-id:group-id /path/to/the/directory
This can happen either becuase the file is in use by another proccess or your user doesn't have access