473,511 Members | 17,577 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Using FileWatcher on a Network Folder in a Service

Hi all,

I developped an C# app which is using FileSystemWatcher. If a file is
created in a specific folder, it opens the file and does some processing.

This functionality works without problems in the following scenarios:
In a Winform App, pointing at a Local Folder
In a Winform App, pointing at a mapped network Folder
In a Winform App, pointing at a UNC network location
In a Windows Service pointing at a local Folder.

I get an System.ArgumentException in system.dll with Additional Information:
The directory name H:\... is invalid when I run the same thing as a Service
looking at a network drive (mapped or using an UNC). I use the same Network
Folder I used in the above scenarios. I doesn't make a difference if I start
it as a User Service or a Local System or anything else.

This is the FileWatcher Code:
this.fileSysWatcher = new System.IO.FileSystemWatcher();
((System.ComponentModel.ISupportInitialize)(this.f ileSysWatcher)).BeginInit();
this.fileSysWatcher.EnableRaisingEvents = true;
this.fileSysWatcher.NotifyFilter = ((System.IO.NotifyFilters)
((((((((System.IO.NotifyFilters.FileName |
System.IO.NotifyFilters.DirectoryName)
| System.IO.NotifyFilters.Attributes)
| System.IO.NotifyFilters.Size)
| System.IO.NotifyFilters.LastWrite)
| System.IO.NotifyFilters.LastAccess)
| System.IO.NotifyFilters.CreationTime)
| System.IO.NotifyFilters.Security)));
this.fileSysWatcher.Path = "H:\\MyFolder";
this.fileSysWatcher.Created += new
System.IO.FileSystemEventHandler(this.fileSysWatch er_Created);

Any ideas? Thank you for taking the time.

Cheers

Peter
Nov 22 '05 #1
1 5835
Update: We (as in my team mate - and I was watching:-) are one step closer.
it now works with a fully qualified network UNC i.e.
//machinename.domain.topleveldomain/sharename

Still no success with a mapped drive, though. But hey, I can live with the
fully qulified UNC.

Cheers

Peter

"PeterNZ" wrote:
Hi all,

I developped an C# app which is using FileSystemWatcher. If a file is
created in a specific folder, it opens the file and does some processing.

This functionality works without problems in the following scenarios:
In a Winform App, pointing at a Local Folder
In a Winform App, pointing at a mapped network Folder
In a Winform App, pointing at a UNC network location
In a Windows Service pointing at a local Folder.

I get an System.ArgumentException in system.dll with Additional Information:
The directory name H:\... is invalid when I run the same thing as a Service
looking at a network drive (mapped or using an UNC). I use the same Network
Folder I used in the above scenarios. I doesn't make a difference if I start
it as a User Service or a Local System or anything else.

This is the FileWatcher Code:
this.fileSysWatcher = new System.IO.FileSystemWatcher();
((System.ComponentModel.ISupportInitialize)(this.f ileSysWatcher)).BeginInit();
this.fileSysWatcher.EnableRaisingEvents = true;
this.fileSysWatcher.NotifyFilter = ((System.IO.NotifyFilters)
((((((((System.IO.NotifyFilters.FileName |
System.IO.NotifyFilters.DirectoryName)
| System.IO.NotifyFilters.Attributes)
| System.IO.NotifyFilters.Size)
| System.IO.NotifyFilters.LastWrite)
| System.IO.NotifyFilters.LastAccess)
| System.IO.NotifyFilters.CreationTime)
| System.IO.NotifyFilters.Security)));
this.fileSysWatcher.Path = "H:\\MyFolder";
this.fileSysWatcher.Created += new
System.IO.FileSystemEventHandler(this.fileSysWatch er_Created);

Any ideas? Thank you for taking the time.

Cheers

Peter

Nov 22 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
1816
by: Ron King Jr | last post by:
I have a small problem with my windows service. The first time I start the service everything works the way it's suppose to, but randomly the service fails. The jist of the service is to use the...
1
971
by: PeterNZ | last post by:
Hi all, I developped an C# app which is using FileSystemWatcher. If a file is created in a specific folder, it opens the file and does some processing. This functionality works without...
1
10041
by: Troy Murphy | last post by:
I seem to remember using a walkthru in the early beta that demonstrated how to create a Windows Service that would monitor events in a folder. Can someone please direct me to an example of doing...
1
8029
by: bivin | last post by:
hai i am requesting your technical support. please help me. i have been working with this for five days. the problem is relating with the smtp. i am trying to send an email from the asp.net...
3
1478
by: Luis Esteban Valencia Muñoz | last post by:
Hi everyone, I created a VB.NET application that looks at a folder in my local system from which I can read the file, enter data into the database and delete the file. I am using the filewatcher...
0
1024
by: Jason | last post by:
I created a FileWatcher service to watch a folder. When a new file is created in the folder, I want to start a process. Everything works fine if I cut-and-paste a test file from my hard-drive; as...
2
3228
by: Dave | last post by:
I've been given the task at work to create a page for the internet. Great, I've never done that before! So I start building. Looks good...flows good...works great internally on the domain, so I...
3
2138
by: tshad | last post by:
Is there some way to have the fileWatcher to initially check the folder to see if there is anything in it (based on the filters)? If I reboot the machine, for example, and it starts up the...
0
1130
by: tshad | last post by:
I have a filewatcher program that is working syncronously (which is how I want it to work). But my program will handle whatever files are in the folder at the time it runs. So when I drop 15...
7
4164
by: tshad | last post by:
What exactly is FileWatcher doing? When you drop 100 files in a folder it is watching, it normally will fire of the event 100 times. In my case, I do all my processing on the first event so I...
0
7245
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7356
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
7427
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
7512
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5671
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4741
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3227
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3214
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1577
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.