By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,558 Members | 1,177 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,558 IT Pros & Developers. It's quick & easy.

FileSystemWatcher unable to watch network drive as a windows service

P: n/a
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.

Mar 20 '06 #1
Share this Question
Share on Google+
6 Replies


P: n/a
You probably need to load the users Profile when the service starts.

Another thing to try is using UNC paths instead.
<km******@gmail.com> wrote in message
news:11*********************@z34g2000cwc.googlegro ups.com...
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.

Mar 20 '06 #2

P: n/a
Brendan,

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

Mar 20 '06 #3

P: n/a
You'll need to P/Invoke into the Win32 API.

One of the functions you're looking for is the LoadUserProfile(...) function
in userenv.

See http://www.pinvoke.net/default.aspx/...erProfile.html for the
details.

Is there a reason UNC paths aren't an option?

<km******@gmail.com> wrote in message
news:11**********************@j33g2000cwa.googlegr oups.com...
Brendan,

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

Mar 21 '06 #4

P: n/a
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--

Mar 21 '06 #5

P: n/a
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.

<km******@gmail.com> wrote in message
news:11**********************@g10g2000cwb.googlegr oups.com...
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--

Mar 21 '06 #6

P: n/a
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.

Mar 23 '06 #7

This discussion thread is closed

Replies have been disabled for this discussion.