Run a process from a FileSystemWatcher only once ...how?
Posted on 2004-04-23
I have a curious problem. I am using a WindowsService with a FileSystemWatcher component that does the following: as soon as I send a bmp image to folder A, the bmp image is converted to a gif image and saved in a folder B, from where the image is sent to a bluetooth device. The problem that I am encountering is that the process of sending the gif image is not executed only once...it keeps on running until I stop it. (i.e. the image is sent more than once). Why is that so? What can I do to make it run only once?
Below is what i've done:
Private Sub FileSystemWatcher1_Changed(ByVal sender As System.Object, ByVal e As System.IO.FileSystemEventArgs) Handles FileSystemWatcher1.Changed
Dim imgFile As System.Drawing.Image = System.Drawing.Image.FromFile("C:\FolderA\image.bmp")
Process.Start("Folder B") 'to open folder where there is the gif image
'''''(I had to use SendKeys to send the image to a bluetooth device, because other
'''''methods, such as the Environment.SpecialFolder.SendTo... , did not work)
Application.Exit() 'I tried this to exit process, but it did not work
Application.ExitThread() 'this did not work either
How can I make the above process run only once and exit?
Thanks in advance for your help.