EonaCat File Watcher
$ dotnet add package EonaCat.FileWatcherclass Program
{
static async Task Main(string[] args)
{
var fileWatcher = new FileWatcher();
fileWatcher.FileChanged += FileWatcher_FileChanged;
// Start watching a directory (with subdirectories)
await fileWatcher.StartWatchingAsync(@"C:\MyFolder", watchSubdirectories: true);
Console.WriteLine("Press any key to stop watching...");
Console.ReadKey();
// Stop watching when done
await fileWatcher.StopWatchingAsync();
}
// Event handler for file changes
private static void FileWatcher_FileChanged(object sender, FileChangedEventArgs e)
{
Console.WriteLine($"File '{e.FilePath}' was {e.ChangeType.ToString().ToLower()}.");
}
}