Unable to copy file. Access to the path is denied

I am working on asp.net 3.5 project on remote machine. I am accessing it using remote desktop. When I build the project, I get error:

Error   62  Unable to copy file "objDebugmyprojname.pdb" to "binmyprojname.pdb". Access to the path 'binmyprojname.pdb' is denied.

Project is under SVN. I deleted the objDebugmyprojname.pdb and tried to run again but getting same error. I am trying to remove thereadonly from the folder but after clicking ok, It becomes readonly again ( i guess because of SVN).

Answers:

Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

I solved this problem by deleting the contentious files from bin folder and rebuilding the project.

Method 2

I solved it by Unchecking the Read-only CheckBox option on folder setting.

Method 3

I had the same issue and I only had to restart the visual studio.
Classic move 🙂

Method 4

I started Visual studio as administrator and that worked.

Method 5

Removed read only flag on whole solution and it worked. Visual Studio 2012+TFS 2013

Method 6

For me, my issue was that my AntiVirus had a handle on the referenced .dll that was used in my solution. Not exactly sure why, plan on researching it later. But killing my AV Service that had the handle, then restarting Visual Studio fixed this issue for me.

Hope this helps those of you who are maybe having to restart your entire PC when this happens, as before I figured this out, it was the only fix to my solution as well.

Method 7

If all else fails try a reboot of your computer – only thing that worked for me.

Method 8

I had this issue with WebActivator.dll

Closing VS and reopening resolved the issue for me

Method 9

Just found this, which worked for me:

Make sure bin isn’t checked in to TFS.

Method 10

I solved it by Unchecking the Read-only CheckBox option on folder setting.than reload the solution again 🙂

Method 11

Just remove the corresponding reference(.dll file) from the References and add it back again using add reference option.I got a similar error,and i have solved it this way.I hope it will help.

Method 12

After trying all the options below, the only solution was to restart the Windows 7.

  • Removed read only flag.
  • Restart the visual studio.
  • Remove the corresponding reference(.dll file) from the References and add it back
  • Make sure bin isn’t checked in to TFS
  • Deleting the contentious files from bin folder

Method 13

I solved it by excluding my bin folder from my project in VS 2012. Right click on the BIN folder and select “Exclude From Project”.

Method 14

If you only get this for select files:

  1. Go to Published file folder
  2. Select the problem Files
  3. Properties
  4. Uncheck Read-Only

Apparently this can occur when Source Control non-checked out files are read only, and then someone just copies specific files.

(I tried other people’s suggestions: giving myself write access to wwwroot, running VS as admin, but for me it was the read-only that did the trick. I specify this answer to point out it is the files at the destination you are trying to publish to.)

Method 15

If you have done some check-in into the bin folder then this issue will come.
Just delete that file and check-in again and build it. It will definitely work.
Note: Please don’t check-in anything into bin folder

Method 16

the error is pretty obvious there
Access to the path ‘binmyprojname.pdb’ is denied.
the user the web console process is running under (not the user you created in the webconsole, the actual windows user), most likely “Network Service” doesnt have permissions to that folder.

You can either
– Right click on that folder, goto permissions and add the “Network Service” user
– Right click on that folder, goto permissions and add the “Everyone” user

that should fix that problem.

Method 17

You might be opened two visual studios for two different solutions. Vs-A is in Debug mode and VsB is erroring out about .pdb file access denied. So remove the debug mode from Vs-A and Rebuild Vs-B. It should work now, without errors.

Good Luck.

Method 18

I resolved it by cleaning all projects individually and then rebuilding them individually in the order of their dependency over each other

Method 19

Suprisingly, using

Thread.Sleep(1000);

was the reason the project failed to compile for me with the same error message. Converting to

Task.Delay(1000).Wait();

solved it.
Command line application, .NET 4.7.2

Method 20

Tip for VS noobs like me: Check you’re looking at the right /bin folder.

Details: To me, “Failed to copy from SomeDependancy/bin/Debug to /bin” sounds like it means the destination is SomeDependancy/bin. But in my application it meant MainProject/bin. I cottoned on to the idea when I discovered I could build the dependencies and only MainProject was failing. I haven’t completed testing yet, but it looks like the suggestion about recreating the folder might now work for me.


All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x