Possible Duplicate:
FileSystemWatcher Fails to access network drive
I wrote a service that monitors a folder in a network share (\\\\machinename\abc\
) and each time a new file is added, it does something with that file.
The code itself works fine when I run it from a test harness, but when I run it as a service I get a System.IO.FileNotFoundException
the moment a new file is added to the network folder, and the service crashes.
The service is running as a User, with my username and password, so I don't know what's going on, especially given that I don't have this problem when I run the code from a test harness from within VS.
******EDIT****** Just wanted to add that I solved the problem. The key is to make sure that the file is readable before attempting to process the file (ie: write a try-catch statement inside a loop and attempt to obtain a FileStream object for the file). Also it's worth noting that for some strange reason this was not an issue when I ran the service from the test harness. Anyway, I'm glad the problem is solved!