Skip to content

Latest commit

 

History

11 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DirectoryWatcher

basic live directory watcher library in c#

Overview

    static void Main(string[] args)
    {
        string desktopPath = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);

        var watcher1 = new DirectoryWatcher(@"D:\smart-cart", TimeSpan.FromSeconds(4));
        var watcher2 = new DirectoryWatcher(desktopPath, TimeSpan.FromSeconds(5));

        watcher1.WhenNewFilesAppear += WriteToConsole;
        watcher2.WhenNewFilesAppear += WriteToConsole;

        watcher1.Start();
        watcher2.Start();

        Console.ReadKey();    
    }

    static void WriteToConsole(object sender, NewFilesInfoEventArgs ea)
    { 
        Console.WriteLine(string.Join("\n", ea.FileNames));
    }

Since implementation is event-driven, it's possible to watch (subscribe) as many as directories you want. And they will work parallel.

Also, different time intervals can be set.

Exposed events

  • SomeFilesMissed
  • NewFilesDetected

About

basic live directory watcher library in c#

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages