[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1509
  • Last Modified:

access denied on copying files?

ok i am trying to copy a file here from  a local source to a remote source
I have verifed i have permission and from the local source i can manually copy files into the directory on the remote source

here is the code
try
                  {
                        int debug = (int) clsLogManager.clsLogger.LoggingLevel.DEBUG;
                        log.WriteToLog(debug, "Attempting to copy local file to remote server");
                        FileInfo local = new FileInfo(localPath+fileName);
                        log.WriteToLog(debug, "Local Path:"+localPath+fileName);
                        FileInfo mapped = new FileInfo(sharedPath+fileName);
                        log.WriteToLog(debug, "Remote Path:"+sharedPath+fileName);
                        if(local.Exists)
                        {
                              log.WriteToLog(debug, "Local File Exists");
                              local.CopyTo(sharedPath+fileName,true);                                                      
                              log.WriteToLog(debug, "Copy successful");
                        }            
                        else
                        {
                              log.WriteToLog(debug, "Local file does not exist");
                        }
                  }
                  catch(Exception ex)
                  {                  
                        log.WriteToLog((int) clsLogManager.clsLogger.LoggingLevel.EXCEPTION, ex.Message);
                  }


Now here is the log data with the error message

 Attempting to copy local file to remote server
DEBUG: -- 5/27/2006 3:24:43 PM -- Local Path:C:\NetShare\Dialer\VoiceFiles\1345216470.wav
DEBUG: -- 5/27/2006 3:24:43 PM -- Remote Path:\\<server name>\Dialer\VoiceFiles\1345216470.wav
DEBUG: -- 5/27/2006 3:24:43 PM -- Local File Exists
EXCEPTION -- 5/27/2006 3:24:43 PM -- Access to the path "\\<server name>\Dialer\VoiceFiles\1345216470.wav" is denied.

like I said i can do this fine by browsing to the remote directory and copying files to it.

any ideas?



I have masked the ip address for obvisous reasons =)
0
CynergySoftware
Asked:
CynergySoftware
  • 6
  • 3
1 Solution
 
anyoneisCommented:
What is in sharedPath? Exactly?

Can you perform the copy by going to a cmd prompt and doing a copy?

Grasping at straws here :-)

David

0
 
CynergySoftwareAuthor Commented:
yes from the command prompt i can manually type the copy

copy C:\NetShare\Dialer\VoiceFiles\1345216470.wav  \\<Server Name>\Dialer\VoiceFiles\1345216470.wav

and it copies just fine
0
 
anyoneisCommented:
This is a Winforms app, right? The program is running using your credentials?

0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
gregoryyoungCommented:
Is your app running as a normal application (or some other type i.e. windows service, asp.net, webservice, etc) where it might be running as another user?
0
 
CynergySoftwareAuthor Commented:
yes it is a windows application
and it is running as the same user that i went through command prompt with
0
 
anyoneisCommented:
OK, you're really gonna think I'm nuts, but does the file already exist? You could add the second parameter to the CopyTo call...

0
 
anyoneisCommented:
Arghh... Pulease ignore that last burst of static... <sigh>
0
 
anyoneisCommented:
How simple is the test for this? Can you just take the code you gave us and put it in a console program and have it fail? Or does it only fail in your real program? Are there other threads involved (http://www.derkeiler.com/Newsgroups/microsoft.public.dotnet.security/2005-04/0183.html
)?

David
0
 
CynergySoftwareAuthor Commented:
Ok it seem the file was in use... so instead of trying to copy it right after it gets created. I am threading out a FileSystemWatch object. and that monitors the folder and copies new and updated files to the remote server as needed. It checks to see if in use. If it is then it sleeps a few seconds and tried again.

anyoneis you reply helped me get to this so awarding points to you....thanks
0
 
anyoneisCommented:
Thanks for the points! And more importantly, thanks for filling the rest of us in on what you found! I used exactly the same technique in a DirectorySweep program I wrote.

David
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 6
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now