R
Richard
I've been looking around and have found plenty of services to run
using a Timer control.
What I want to do is have a FileSystemWatcher to run as a service and
tell me when a new file has been created in a directory.
Here is my code.
Protected Overrides Sub OnStart(ByVal args() As String)
Dim fsWatcher As New FileSystemWatcher("C:\temp")
fsWatcher.Filter = "*"
fsWatcher.NotifyFilter = (NotifyFilters.LastAccess Or
NotifyFilters.LastWrite Or NotifyFilters.FileName)
AddHandler fsWatcher.Created, AddressOf OnChanged
fsWatcher.EnableRaisingEvents = True
End Sub
Private Shared Sub OnChanged(ByVal source As Object, ByVal e As
FileSystemEventArgs)
MsgBox("New sync file in C:\temp")
End Sub
The service runs once but then stops because it has no work to do....
How do I keep this service alive?
Thanks in advance
- Rich
using a Timer control.
What I want to do is have a FileSystemWatcher to run as a service and
tell me when a new file has been created in a directory.
Here is my code.
Protected Overrides Sub OnStart(ByVal args() As String)
Dim fsWatcher As New FileSystemWatcher("C:\temp")
fsWatcher.Filter = "*"
fsWatcher.NotifyFilter = (NotifyFilters.LastAccess Or
NotifyFilters.LastWrite Or NotifyFilters.FileName)
AddHandler fsWatcher.Created, AddressOf OnChanged
fsWatcher.EnableRaisingEvents = True
End Sub
Private Shared Sub OnChanged(ByVal source As Object, ByVal e As
FileSystemEventArgs)
MsgBox("New sync file in C:\temp")
End Sub
The service runs once but then stops because it has no work to do....
How do I keep this service alive?
Thanks in advance
- Rich