Issue copying to a network share  
Author Message
Quilnux





PostPosted: Visual C# General, Issue copying to a network share Top

I have a windows service that is responsable for copying files to a network drive at certain times. I use the IO.File.Copy() method to do this. everytime I run it with the network path I get this error: The network path was not found. I even tried a network path without spaces (my test share has spaces in the name) which gave the same. the share can be read and written to by everyone with full control to admins. The service runs under the system context. Any suggestions

Thanks,

Quilnux



Visual C#17  
 
 
ahmedilyas





PostPosted: Visual C# General, Issue copying to a network share Top

remember, Windows Service runs under a different account that your user account so any drives you have already "opened" in your account will not be accessed/seen by the other account. you need to access/make a connection to that network share in the other account too.

you could change the user account that the Windows Service is going to run under however it would defeat the purpose of having a seperate account to run Windows Services. To change the account to your user account, open the services MMC then select your service and change the account to your account



 
 
Quilnux





PostPosted: Visual C# General, Issue copying to a network share Top

I know that I "could" do that but, this application is deploying on systems that cannot use a seperate user account for services. It has to use the System account or, computer-based account (Local service/Network service). Is this error due to a permissions issue or, because the system account is not permitted network access
 
 
ahmedilyas





PostPosted: Visual C# General, Issue copying to a network share Top

I think, but could be wrong, its to do with it not being able to instantiate the connection to the network drive/share folder.

What happens if you create a net share by say, executing a process which creates the share use the System.Diagnostics.Process to spin up the net share command (look at the command switches) and see if it can map that drive, if so, then see if it can access it. Does that work



 
 
Gabriel Lozano-Moran





PostPosted: Visual C# General, Issue copying to a network share Top

Download and run Filemon:

Look at the result when trying to write to the network share, possible values:

  • BAD NETWORK PATH
  • ACCESS DENIED
  • ...


 
 
Quilnux





PostPosted: Visual C# General, Issue copying to a network share Top

Sorry to take so long getting back to you. It's been a busy holiday for me. Since the project has been pushed to a release I have had to put this on hold for now. I will try the net share suggestion as well as the filemon application to see what I get after deployment. Maybe I can make it work before for first update.

Thanks for the replies. I will let you all know my findings.

Merry Christmas.

Quilnux