By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
458,193 Members | 1,794 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 458,193 IT Pros & Developers. It's quick & easy.

FileSystemWatcher in Service App on Windows 2000 Server

P: n/a
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

Jul 21 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
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.

"Rich Miller" <rm*****@noplace.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
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

Jul 21 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.