SmartDirWatcher 1.0.2

dotnet add package SmartDirWatcher --version 1.0.2
NuGet\Install-Package SmartDirWatcher -Version 1.0.2
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="SmartDirWatcher" Version="1.0.2" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add SmartDirWatcher --version 1.0.2
#r "nuget: SmartDirWatcher, 1.0.2"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// 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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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.

Version Downloads Last updated
1.0.2 1,085 1/8/2019
1.0.1 723 10/12/2018

Fixed a bug where filenames with capital letters where not recognized.