Click here to Skip to main content
15,922,007 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a small desktop utility, written in C#, that copies a file from a network share to a work location on the users local drive then continues processing. It worked previously and there have been no major changes to the network setup, however, I am now getting...

"Access to the path '\\server\volume\chapter\page\filename\version\filename.ext' is denied."

I have admin permissions on my machine and read rights on the network source. I can manually copy the file with no problem.

Any suggestions would be appreciated.
Posted
Comments
Kornfeld Eliyahu Peter 25-Feb-14 14:07pm    
Try to run you app with 'Run as Administrator' - let see if elevation helps...

I have no idea why above message is displayed now, especially when it worked previously and stop working now. I can suspect only that the reason is in the way how windows provides rights to shared folders. Few years ago (about 2), i had the same problem on 2 workstations...

Try to do that:

  1. map shared folder to drive letter and use it instead path to the shared folder
  2. or/and
  3. follow this instruction: "Access Denied" When Accessing a Share in Windows Home Server[^]


Don't forget to restart your local computer!
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 25-Feb-14 16:30pm    
Good points, a 5.
—SA
Maciej Los 25-Feb-14 16:34pm    
Thank you, Sergey ;)
Check if another instance of the same program is holding the file.
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 25-Feb-14 14:04pm    
I think that's not it, then the exception says "file is used by another process". This must be permission.
(I did not vote, by the way. Someone down-voted both answers, probably...)
—SA
Admin permission on your account is not enough. To start with, try to run this application with elevated privileges. Please see:
http://msdn.microsoft.com/en-us/library/bb756929.aspx[^].

Check up permissions of the shared file system objects involved.

—SA
 
Share this answer
 
Comments
Maciej Los 25-Feb-14 15:17pm    
Sergey, i'am wondering why OP can manually copy the file and can't do the same using 'desktop utility'...
Op wrote that he has got admin permission on local machine and read rights on server.
Why his program worked previously and now stop working? There must be something else.
By the way: i did not vote.

Have a look at my answer.
Sergey Alexandrovich Kryukov 25-Feb-14 16:30pm    
Thank you, Maciej.
This is probably the same down-voting action you paid your attention before. You just posted your answer later... :-)
—SA
Dave Kreskowiak 25-Feb-14 17:40pm    
Well, I countered all the one votes but it looks like whoever downvoted carries about as much weight as I do in the voting results.
Sergey Alexandrovich Kryukov 25-Feb-14 17:48pm    
In most cases, not, but in other cases, raid of couple of unreasonable voted of higher rank happened... I don't care much...
Thank you, Dave.
—SA
There are only two possibilities.

1) You don't have permissions to some part of the filepath. You really can't do anything about this in your code.

2) The file is still open, denying shared access to the file, at the time your code tries to copy it. A typical technique is to catch the error, wait a few seconds and retry copying the file. After a few attempts at this, your code can throw an appropriate error to the user.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900