https://github.com/stefh/filewatcher
FileWatcher
https://github.com/stefh/filewatcher
Last synced: about 1 year ago
JSON representation
FileWatcher
- Host: GitHub
- URL: https://github.com/stefh/filewatcher
- Owner: StefH
- License: mit
- Created: 2022-02-19T10:57:28.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2022-02-19T16:15:37.000Z (over 4 years ago)
- Last Synced: 2025-05-06T21:36:34.831Z (about 1 year ago)
- Language: C#
- Size: 22.5 KB
- Stars: 4
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# FileWatcher
This project is based on:
- https://github.com/Microsoft/vscode-filewatcher-windows
- https://github.com/d2phap/FileWatcherEx
## NuGet
[](https://www.nuget.org/packages/Stef.FileWatcher)
## Features
- Standardize the events of C# `FileSystemWatcher`.
- No false change notifications when a file system item is created, deleted, changed or renamed.
- Supports .NET 4.5, .NETStandard (1.3, 2.0 and 2.1), .NET Core 3.1, .NET 5 and .NET 6
## Usage
See Demo project for full details.
``` c#
using Stef.FileWatcher;
var path = @"C:\temp\fs";
Console.WriteLine("Watching {0}", path);
var fileWatcher = new FileWatcher(path)
{
IncludeSubdirectories = true
};
fileWatcher.OnCreated += OnX;
fileWatcher.OnDeleted += OnX;
fileWatcher.OnChanged += OnX;
fileWatcher.OnRenamed += OnX;
// start watching
fileWatcher.Start();
Console.WriteLine("Press a key to exit");
Console.ReadKey();
void OnX(object sender, FileChangedEvent e)
{
Console.WriteLine($"{e.ChangeType} | {e.FullPath}");
}
```
## License
[MIT](LICENSE)