Only if you invite me over to stay in NZ for a month!
For now, just move the declaration out of the method.
Code:Private WithEvents TheFileWatcher As FileSystemWatcher Public Function fnWatchFolder(ByVal strFolderToWatch As String, ByVal strFileExtension As String) As Boolean ' Get the path to the directory we will watch. ' Make the FileSystemWatcher. TheFileWatcher = New FileSystemWatcher(strFolderToWatch, strFileExtension) TheFileWatcher.NotifyFilter = NotifyFilters.FileName ' Or NotifyFilters.FileName TheFileWatcher.EnableRaisingEvents = True ' AddHandler FileWatcher.Changed, AddressOf OnChanged You can use the WithEvents above to just xxx Handles TheFileWatcher.Changed event Return True End Function




Reply With Quote