A library for cyclical asynchronous file watching with subscription support.
Unlike another file watching solutions that rely on OS-level tools or native file system event hooks, CyclicalFileWatcher uses a simple polling mechanism to detect changes.
This approach:
- Works consistently across platforms and environments (e.g. Docker, network drives, cloud volumes).
- Requires no external dependencies, system utilities, or file system support.
- Gives you full control over polling intervals and error handling.
It’s ideal for scenarios where reliability and isolation from the underlying OS are more important than real-time change detection.
var fileWatcher = new CyclicalFileWatcher<FileObject>(configuration);
await fileWatcher.WatchAsync(parameters, cancellationToken);
await fileWatcher.SubscribeAsync(filePath, async _ =>
{
Console.WriteLine("Subscription action executed");
}, cancellationToken);
var latestFile = await fileWatcher.GetLatestAsync(filePath, cancellationToken);See the full example in src/CyclicalFileWatcher.Test/Program.cs
Released under MIT by @EvgenyHalzov.
- You can freely modify and reuse.
- The original license must be included with copies of this software.
- Please link back to this repo if you use a significant portion the source code.