FileSystemWatcher unable to watch network drive as a windows service

K

kmpodury

PLEASE HELP!!!!!!

Here is the exception that I am getting

Exception: System.ArgumentException
Message: The directory name W:\AudioFiles is invalid.
Source: System
at System.IO.FileSystemWatcher.set_Path(String value)
at DirMon.set_sourceDirectory(String value)

The service is running under local administrator account. The drive is
mapped and is accessible.

If I run the same code through an EXE and logged in as the same, it
works just fine.

The W:\AudioFiles is shared with unlimited users and full control.

This is driving me nuts.
 
B

Brendan Green

You probably need to load the users Profile when the service starts.

Another thing to try is using UNC paths instead.
 
K

kmpodury

Brendan,

Thanks for the reply. Can you point me in the right direction for
loading user's profile when the service starts?
 
K

kmpodury

Brendan,

Thanks for the reply. The UNC paths are an option to use but I would
imagine the remote machine would ask for userid, password and domain
when attempting to access the UNC path. The tight deadline that is
looming on my head is making it look for a quick fix. With a mapped
drive, I could just set the "Reconnect at logon" property and never
again worry about providing the userid and password.

I am surprised to find that windows service does not have a
LoadUserProfile property that one could set. I believe the windows
service does not load the user's profile as a perfomance tweak, but the
option should always be with the developers to take the performance
hit.

Thanks
Kris--
 
B

Brendan Green

I'm not 100% sure of the details, but you might be able to use UNC paths if
you run the service as a domain user who has access to the share on the
remote machine.

If services are run as users such as Local System or Local Service, they are
very limited.

Good luck with finding a solution.
 
K

kmpodury

Thanks. I tried to monitor using UNC path and it seems to work. I will
implement impersonation if the service starts complaining. If not, I'm
good to go. Thanks a lot for the advice.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top