Camera will capture image and store in a folder(.bmp file).Simultaneously our application needs to get one by one image file from the folder for processing.(captured images will update the folder dynamically.If we use FileSystemWatcher , it may cause problem for us.(We are selecting the directory before processing of the image,so updated images will not process.Is there any solution for this problem)how to get one by one image from the folder at run time?
Camera will capture image and store in a folder(.bmp file).Simultaneously our application needs to
Share
You can use FileSystemWatcher but you need to be aware of a few quirks. The watcher will raise a Created event when a file is first created and one or more Modified events as data is written to the files. There is no Close event so you can’t know when the camera has stopped writing to the file.
As long as the file is open for writing, you won’t be able to read it for processing and any attempt to read it will raise an exception
There are several ways you can handle this:
Polling and timeouts can be implemented using timers.
If you don’t like the delay introduced by polling, you can use a separate thread to wait on the list of events and process new events as they appear. You can use the functionality of the BlockingCollection in C# 4 to do this in a relatively simple way.