Whats wrong with my FileSystemWatcher
I have code written that is supposed to watch a folder on my harddrive and when it sees that a new file has been created it is supposed to, for simplicity, pop up a message box and say it found it. The problem is that it runs through the routine (TDlogchange) that is supposed to be called when the file is found, several times instead of just once.
My understanding of the code was that it should only do it once when it sees a new file created. Below is the code. Any help would be great.
Dim TDFPath AsString = "C:\Data\KOHIN\"
PublicWithEvents TDwatchfolder AsNewFileSystemWatcher(TDFPath, "*.txt")
PrivateSub SetupNextEtchTankD()
TDwatchfolder.Path = TDFPath
TDwatchfolder.NotifyFilter = NotifyFilters.FileName
TDwatchfolder.EnableRaisingEvents = True
EndSub
PrivateSub TDlogchange(ByVal source AsObject, ByVal e As System.IO.FileSystemEventArgs) Handles TDwatchfolder.Created
MsgBox("Found the File!!!", MsgBoxStyle.OkOnly, "Tank D")
EndSub
|