Click here to Skip to main content
15,392,442 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
Hi All,

I want a application to watch Directory using FileSystem Watcher or any other method.

if any file(s) paste in that directory , I can move or do any other action.

if i paste single file it is working fine.
if i paste multiple file it is just taking last file and ignore rest of the files.

I am using below program from codeproject

C#: Application to Watch a File or Directory using FileSystem Watcher[^]

Can you help me in this?

thanks you.


1 solution

Hello Asutosha,

The MSDN documentation[^] for FileSystemWatcher class clearly outlines the problem you are facing.
The Windows operating system notifies your component of file changes in a buffer created by the FileSystemWatcher. If there are many changes in a short time, the buffer can overflow. This causes the component to lose track of changes in the directory, and it will only provide blanket notification. Increasing the size of the buffer with the InternalBufferSize property is expensive, as it comes from non-paged memory that cannot be swapped out to disk, so keep the buffer as small yet large enough to not miss any file change events. To avoid a buffer overflow, use the NotifyFilter and IncludeSubdirectories properties so you can filter out unwanted change notifications.

Hope this helps you correct your code.

Asutosha 26-Jun-13 5:05am
can you modify and send me the sample code..
I will appreciate if i get

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900