473,473 Members | 1,739 Online
Bytes | Software Development & Data Engineering Community
Create 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 5820
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
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
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
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
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
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
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
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
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
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
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
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
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
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...
1
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...
0
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,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
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 ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.