Link to home
Avatar of James Cochrane
James CochraneFlag for United States of America

asked on

FileSystemWatcher control in a Windows Service.

Hi,

Can a FileSystemWatcher control in a WIndows Service watch a shared network drive? The Service crashes and then when Visual Studio debugs it, I get a message stating that the directory is invalid.  I know it is a valid location since I used the browse button to get to it.  But I also copied the path and went to file explorer and it went to the correct path.

THanks
Avatar of dstanley9
dstanley9

As long as it uses a UNC path and not a mapped drive it should work.  If you have a network interruption, though, your service will crash and you'll have to re-start it:

http://www.codeguru.com/csharp/.net/net_general/tipstricks/article.php/c9113/
http://www.dotnet247.com/247reference/msgs/57/289450.aspx
Avatar of James Cochrane

ASKER

When you state UNC path you are referring to the path that looks similar to the following:

\\MyServer\c$\somedrive

If that is true, I tried that as well.  I cannot seem to get either to work.
Does the account that the service is running as have access to the share?
Hi, sorry I haven't gotten back to you sooner.  I set it up with Local Service and Local System access but I do not know whether or not either of those have access.
ASKER CERTIFIED SOLUTION
Avatar of dstanley9
dstanley9

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial