Note: I've been able to duplicate my problem by using another WinXp computers instead of a USB drive plugged into my router. Same exact problem. So, the bottom line is that I can access (and modify) the files across the network if I'm doing so manually, but my Windows service fails when trying to do the same thing. If I run the program through Visual Studio, it works. If I run that same exact code as a Windows service, it fails.
I've created a Windows service that needs to access a common network location. To test it at home, I plugged a USB drive into my Netgear N600 WNDR3400 router. The USB storage settings show the workgroup name as Workgroup, and the file path is:
\\readyshare\USB_Storage
The service can't access the files within that network folder. I get an error that the file can't be found, or that permission was denied, depending on what I try. (The file does indeed exist.) However, I can access/modify those files directly from my laptop (Win8), and I can do the same thing on my wife's laptop (WinXP). The service is running as the Local System
user.
I've tried running as Network Service
, as .\administrator
, and as .\JaneDoe
. No luck.
I also tried changing the permissions on the newtwork folders, but it doesn't stick. For example, if I try to give Everyone
full control:
It just reverts to the previous state after I hit apply:
I've also tried adding a new user (see Add button above), but then I get this error:
Any ideas how I can make this work? I simply want my service to have read/write (even full, I don't care) access to the folders on this network.
Edit - I used Process Monitor, and, as expected, this is the error:
More Failed Attempts
- Use different USB drive
- Disable Windows firewall on the XP box
- Instead of using the UNC path, use a mapped drive
EDIT - Code to Access the Network Files Note: The file is not found (even though it exists).
private UpdaterManifest GetUpdaterManifest()
{
string filePathAndName = Path.Combine(this._sourceBinaryPath, this._appName + ".UpdaterManifest");
if (!File.Exists(filePathAndName))
{
// Always hit here
}
}