RaiseEvent / Simulating control event
I want to simulate a File System Watcher's created event. When the service starts, I want to iterate through all the files in a watcher's input directory and process like I would if the service had been running. I've got this
Code:
Protected Function MoveExistingFiles(ByVal fsw As System.IO.FileSystemWatcher) As Boolean
Try
For Each existingFile As String In IO.Directory.GetFiles(fsw.Path, fsw.Filter)
Dim newArgs As New IO.FileSystemEventArgs(IO.WatcherChangeTypes.Created, fsw.Path, _
IO.Path.GetFileName(existingFile))
OnCreated(fsw, newArgs)
Next
Return True
Catch
Return False
End Try
End Function
The problem is now I call the event handler directly. If I've got two FSWs with seperate create handlers, this won't work. What I would like to do is fire off the FSW's Created event. I'm not sure if this is possible, but I figured I would ask.