SmartDirWatcher 1.0.2
dotnet add package SmartDirWatcher --version 1.0.2
NuGet\Install-Package SmartDirWatcher -Version 1.0.2
<PackageReference Include="SmartDirWatcher" Version="1.0.2" />
paket add SmartDirWatcher --version 1.0.2
#r "nuget: SmartDirWatcher, 1.0.2"
// Install SmartDirWatcher as a Cake Addin #addin nuget:?package=SmartDirWatcher&version=1.0.2 // Install SmartDirWatcher as a Cake Tool #tool nuget:?package=SmartDirWatcher&version=1.0.2
SmartDirWatcher
An alternative to the native .NET FileSystemWatcher which always causes several problems to many users. This library is based on implementation of W32 API to get system internal file indices. Then an internal object can identify if a file is newly created, changed or deleted.
Implement the SmartDirWatcher
After loading the nuget package the implementation is quite simple. Just instance an object, connect the eventhandler and start the watcher. You can define watching for a specific file extension or for an explicit filename.
Watch for a extension
Watcher smartWatcher = new Watcher("directory/to/watch/for/files", ".dll", WATCHMODE.Extension);
smartWatcher.DirWatcherEventRaised += OnFolderFilesChanged;
smartWatcher.Start();
Watch for a specific filename
Watcher smartWatcher = new Watcher("directory/to/watch/for/files", "awesome.txt", WATCHMODE.FileName);
smartWatcher.DirWatcherEventRaised += OnFolderFilesChanged;
smartWatcher.Start();
How to handle events.
After an instance of SmartDirWatcher is up and running, everytime something happens within the folder you watching, an event will been fired throug the event handler. Be sure to cast EventArgs to DirWatcherEventArgs to handle the fired event type. You can then select the event you want to interact with and do whatever you want to.
protected void OnFolderFilesChanged(object sender, EventArgs e)
{
DirWatcherEventArgs args = e as DirWatcherEventArgs;
switch (args.Type)
{
case EventType.Created:
// Do something
break;
case EventType.Changed:
// Do something
break;
case EventType.Deleted:
// Do something
break;
}
}
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET Framework | net461 is compatible. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
This package has no dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Fixed a bug where filenames with capital letters where not recognized.