FileSystemWatcherAlts
FileSystemWatcherAlts copied to clipboard
A collection of alternatives to the System.IO.FileSystemWatcher class.
⚠️ This project is not maintained.
I suggest seeking other solutions like this one:
https://petermeinl.wordpress.com/2015/05/18/tamed-filesystemwatcher/
![]()
FileSystemWatcherAlts
Resolving your files watching trust issues since 2015.
What Is This?
A collection of alternatives to the System.IO.FileSystemWatcher class.
What's Wrong With System.IO.FileSystemWatcher?
As you can see with a quick google search - FilesystemWatcher is far from perfect. In fact, it is problematic enough that Microsoft gave it an "Error" event so you can react when it encounters a problem. To put it in simple words, there are 2 main issues with it:
- It misses file changes when under heavy load, rendering it unreliable.
- It stops working under certain circumstances.
Show Me What You Got
The alternatives offered are:
FileSystemPoller- Periodicly polls for file system changes.FileSystemRefreshableWatcher- A watcher wrapper. Allows the user to restart a broken watcher.FileSystemAutoRefreshingWatcher- A watcher wrapper. Automatically restarts a watcher if it breaks.FileSystemOverseer- A watcher wrapper. Automatically restarts a watcher if it breaks and uses a backup poller for increased reliability.
The table over here shows you the upsides and downsides of FileSystemWatcher and my alternatives. Choose the one that fits your requirements.
Usage
All alternatives in this library implements an interface called "IFileSystemWatcher" It defines methods and events corresponding to the ones in System.IO.FileSystemWatcher. If your project is already utilizing FileSytemWatcher you can simply change this:
FileSystemWatcher sysMonitor = new FileSystemWatcher(@"C:\");
To any of those:
IFileSystemWatcher sysMonitor = new FileSystemRefreshableWatcher(@"C:\");
IFileSystemWatcher sysMonitor = new FileSystemAutoRefreshingWatcher(@"C:\");
IFileSystemWatcher sysMonitor = new FileSystemPoller(pollingInterval: 500,path: @"C:\");
IFileSystemWatcher sysMonitor = new FileSystemOverseer(pollingInterval: 500, path: @"C:\");
Then use Created/Deleted/Renamed/Changed events as you would with FileSystemWatcher.
Thanks
Icon: Binoculars designed by Gregor Crešnar from The Noun Project