Using FileWatcher on a Network Folder in a Service

G

Guest

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.fileSysWatcher)).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.fileSysWatcher_Created);

Any ideas? Thank you for taking the time.

Cheers

Peter
 
G

Guest

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
 

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