⚠ Deprecated: Legacy
Suggested alternative: D2Phap.FileWatcherEx
A wrapper of FileSystemWatcher to standardize the events and avoid false change notifications, used in ImageGlass project (https://imageglass.org). This project is based on the VSCode FileWatcher: https://github.com/Microsoft/vscode-filewatcher-windows.
$ dotnet add package FileWatcherExA wrapper of System.IO.FileSystemWatcher to standardize the events and avoid false change notifications. It has been being used in ImageGlass - A lightweight, versatile image viewer project.
This project is based on the VSCode FileWatcher: https://github.com/Microsoft/vscode-filewatcher-windows
System.IO.FileSystemWatcher.Run the command:
# Nuget package
Install-Package FileWatcherEx
See Demo project for full details!
using FileWatcherEx;
var _fw = new FileSystemWatcherEx(@"C:\path\to\watch");
// event handlers
_fw.OnRenamed += FW_OnRenamed;
_fw.OnCreated += FW_OnCreated;
_fw.OnDeleted += FW_OnDeleted;
_fw.OnChanged += FW_OnChanged;
_fw.OnError += FW_OnError;
// thread-safe for event handlers
_fw.SynchronizingObject = this;
// start watching
_fw.Start();
void FW_OnRenamed(object sender, FileChangedEvent e)
{
// do something here
}
...
Thanks for your gratitude and finance help!