Visual Studio Publish Failed: "Unable to delete file ... Access to the path ... is denied."

I noticed that my folders were read-only. I changed that.

It worked! Publish succeeded.

Folder Properties Read-only


I believe your issue is related to the default permissions assigned the to C: drive in windows 7 (and Vista).

  1. Open explorer and find the c:\code folder
  2. Right click on the c:\code folder and select properties
  3. select the security tab
  4. select the user ID "Users"
  5. In the permissions box, tick the "modify" allow box
  6. Select OK, OK until permision dialog boxes close

That should resolve the permission issue


The most likely cause is a permissions issue. The path in question may have been created while you were running with elevated permissions and hence requires admin permissions to delete. Try running Visual Studio as an admin and see if the problem goes away.

If so then the best solution is to do the following

  1. Save the changes to that directory (check in if necessary)
  2. Delete the repository
  3. Re-check out the repository and ensure you are not running as an admin when doing so