473,394 Members | 1,722 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

FileSystemWatcher unable to watch network drive as a windows service

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
6 10724
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
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
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Robert Tarantino | last post by:
Hello, I am trying to find a way to create a scheduled task or service that will copy my local profile folders under "Documents and settings" to a network drive. This would allow me to restore...
2
by: Jet Leung | last post by:
Hi all, I had made a program to watching files in my directory. I had used a instance of FileSystemWatcher to do my work.And I had add some events of the FileSystemWatcher , for example onChange,...
1
by: John Lee | last post by:
Hi, I developed a filewatcher service to monitor file creation on a network drive - 90% time it works fine and from time to time I found out that the newly created file on that network drive...
20
by: J-T | last post by:
We are working on an asp.net application which is a 3-tier application.I was aksed to create a component which monitors a folder and gets the file and pass them to a class library in our business...
8
by: Pedro C. Valenzuela | last post by:
Hello, Does anyone know how a File System Watcher windows control works to detect file changes accross the network to a remote machine? I am trying to watch for new files in 30 different...
1
by: Adrian | last post by:
I am trying to use FileSystemWatcher (FSW) to monitor a folder. The only problem is this folder is on FTP server located on DMZ (outside my domain) and FSW does not allow me to pass credentials in...
9
by: Tushar | last post by:
Followup-To: microsoft.public.dotnet.general Does anyone know when is this event raised, is it: 1) When the file is created but may not have been closed 2) When the file is created AND it has...
3
by: webgreginsf | last post by:
I'm attempting to use the FileSystemWatcher class to monitor a folder on a remote server. My app is running as a Windows service, currently on an XP machine, but it will be on Server 2003 in...
5
by: Goran Djuranovic | last post by:
Hi all, I have a file system watcher service that works fine on a local hard drive, but will not work across the network. I tried both: mapping the drive and "\\..." path both no luck. I don't...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.