Pawan Agrawal
Pawan Agrawal

Reputation: 432

How to monitor change in files in windows system in c# using filesystemwatcher

Currently i am using filesystemwatcher class to watch the file changes But in my case i have millions of file on different- different location in the system, so i have to create millions instance of fileststemwatcher class which is causing the performance issue.

Please tell how can i maximize the performance or is there another way to monitor the all files in c#.

Upvotes: 3

Views: 1186

Answers (1)

Michael
Michael

Reputation: 9044

FileSystemWatcher is the normal way. I suggest you watch for files at a higher level - eg. all changes at the drive level, and only respond to those that are in folders you are interested in.

Once you get a "Changed" event for example, you can check the FullPath property on the FileSystemEventArgs that is passed to your event handler.

And I assume you are already watching at a folder-level, not individual files.

Upvotes: 3

Related Questions