Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / General / September 2005

Tip: Looking for answers? Try searching our database.

Using FileWatcher on a Network Folder in a Service

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
PeterNZ - 21 Sep 2005 04:48 GMT
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
PeterNZ - 21 Sep 2005 05:25 GMT
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

> Hi all,
>
[quoted text clipped - 35 lines]
>
> Peter

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.