But There is a problem when handling a large amount of files through the File System Watcher.
- There is a fixed buffer allocated to each file system watcher (Default size of the buffer is 4 KB).
- This Buffer is used to store the details such as file location for each file that raises an event.
- When a large number of files raise an event then this buffer gets full.
- So there is a possibility of missing some file information.
- Do not write the proceeding logic in the handler instead the handler simply queues the file in a work queue.
- Queue is processed by an entirely independent thread.
- So the actual work done by the handler is just queuing and the control moves out of the handler thus releasing the buffer.
- In Main
- Event Handler
- Process
References :- http://csharp-codesamples.com/2009/02/file-system-watcher-and-large-file-volumes/