FileSystemWatcher in Service App on Windows 2000 Server

R

Rich Miller

Previously posted on the VB newsgroup with no replies, so any ideas
appreciated. I have written a service application in VB (VS.Net 2003). On
start, the service creates an object that instantiates a
System.IO.FileSystemWatcher like so (the _watcher is
declared at the class level as Private and no WithEvents):

' construct the file watcher
_watcher = New FileSystemWatcher
_watcher.Path = WatchPath
_watcher.NotifyFilter = (NotifyFilters.FileName Or NotifyFilters.Size
Or NotifyFilters.CreationTime)
_watcher.Filter = WatchFilter
AddHandler _watcher.Created, AddressOf OnCreated

' begin watching for file events
_watcher.EnableRaisingEvents = True

OnCreated looks like this:

Private Sub OnCreated(ByVal source As Object, ByVal e As
FileSystemEventArgs)

Dim strFileName As String
Dim procQueue As BaseFileProcessor
Dim ft As FileTaskInfo
Dim bResult As Boolean

' this sub only handles the watcher created notification
messages
If e.ChangeType <> WatcherChangeTypes.Created Then
Exit Sub
End If

' do stuff here

..
..
..
End Sub

This all works really well on my development box. Installutil
installs the service running as Local System, the service starts and
files dropped in the watched directory are processed. However, this
does not work after installing on a Windows 2000 server. The
FileSystemWatcher appears not to be getting *any* notifications. I
have installed and run the service both as Local System and under a
special user account with "Run as service" set. All accounts have
sufficient permissions to access the watched directory, which is on
the same machine but a different logical partition than the service
exe. The path to the watched directory is specified as
"e:\directory\subdirectory".

A Google search turned up a lot of messages about the apparent
ineffectiveness of FileSystemWatcher in receiving all notifications in
a volume environment, and I am beginning to feel like I should move
toward using a polling approach. This just seemed more elegant and
efficient. Has anyone had any trouble of this kind that you were able
to solve? Have I overlooked something on the operating system
security side that I should look at?

I'd be glad to get any useful tips from experience or URLs for
information that might be useful.

Thanks.

Rich
 
R

Rich Miller

Thanks to anyone who tried to help. Problem turned out to be unrelated to
FileSystemWatcher, rather having to do with an outdated (2.5) version of
MDAC installed on the server (the app was writing notifications to a
database) and insufficient privileges for the system account to access
various folders where it was attempting to move files.
 

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