G2Development.FileWatcher 2.0.1.1

There is a newer version of this package available.
See the version list below for details.
dotnet add package G2Development.FileWatcher --version 2.0.1.1                
NuGet\Install-Package G2Development.FileWatcher -Version 2.0.1.1                
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="G2Development.FileWatcher" Version="2.0.1.1" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add G2Development.FileWatcher --version 2.0.1.1                
#r "nuget: G2Development.FileWatcher, 2.0.1.1"                
#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 G2Development.FileWatcher as a Cake Addin
#addin nuget:?package=G2Development.FileWatcher&version=2.0.1.1

// Install G2Development.FileWatcher as a Cake Tool
#tool nuget:?package=G2Development.FileWatcher&version=2.0.1.1                

File Watcher

A File Watching module similar to FileSystemWatcher from Microsoft. The need arose to find a Watching module to monitor file changes inside of a Docker container where the files might be changed by the Host computer. It seems as if these changes is not monitored by FileSystemWatcher.

An attempt was made to keep the naming conventions very close to that of the FileSystemWatcher where possible. The usage will also be similar. Have a look at Diferences and Official Page

Examples

The following example creates a FileWatcher to watch the directory specified at run time. The component is set to watch for changes of any Notification type in the directory. This is similare to FileSystemWatcher.

public class Watcher
{
    public static void Main()
    {
        Run();
    }

    private static void Run()
    {
        string path = "../../../test";

        // Create a new FileWatcher and set its properties.
        using FileWatcher watcher = new FileWatcher
        {
            Path = path,

            // Watch for changes in LastAccess and LastWrite times, and
            // the renaming of files or directories.
            NotifyFilter = NotifyFilters.LastAccess
                                | NotifyFilters.LastWrite
                                | NotifyFilters.FileName
                                | NotifyFilters.DirectoryName,

            IncludeSubdirectories = true,

            // Only watch text files.
            Filter = "*.txt"
        };

        // Add event handlers.
        watcher.Changed += OnChanged;
        watcher.Created += OnChanged;
        watcher.Deleted += OnChanged;
        watcher.Renamed += OnRenamed;

        // Begin watching.
        watcher.EnableRaisingEvents = true;

        // Wait for the user to quit the program.
        Console.WriteLine("Press 'q' to quit the sample.");
        while (Console.Read() != 'q') ;
    }

    // Define the event handlers.
    private static void OnChanged(object source, FileSystemEventArgs e) =>
        // Specify what is done when a file is changed, created, or deleted.
        Console.WriteLine($"File: {e.FullPath} {e.ChangeType}");

    private static void OnRenamed(object source, RenamedEventArgs e) =>
        // Specify what is done when a file is renamed.
        Console.WriteLine($"File: {e.OldFullPath} renamed to {e.FullPath}");
}

Note the above example has been taken from Microsoft's site to illustrate similarities.

Refer to Project Page for more information.

Versioning

2.0.1

  • Add Error event.
  • Improved Error handling.

2.0.0

  • Brought more in line with FileSystemWatcher
  • Added a Wrapper Class.
  • Some breaking Changes between version 1 and 2 to bring it in line with FileSystemWatcher and Wrapper Usage.

1.0.0

  • Initial Release.
Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp3.1 is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETCoreApp 3.1

    • 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
2.0.1.3 10,027 9/29/2020
2.0.1.2 476 9/29/2020
2.0.1.1 465 9/29/2020
2.0.1 402 9/29/2020
2.0.0 386 9/28/2020
1.0.1 476 9/25/2020
1.0.0 500 9/25/2020

FileWatcher brought more in line with FileSystemWatcher and added an additional FileWatcherWrapper class.