Exemple #1
0
 public DirectoryWatcher(Action <object, System.IO.FileSystemEventArgs> Changed = default, Action <object, System.IO.FileSystemEventArgs> Created = default, Action <object, System.IO.FileSystemEventArgs> Deleted = default, Action <object, System.IO.RenamedEventArgs> Renamed = default
                         , string Path = default, string Filter = default, System.IO.NotifyFilters NotifyFilters = default, System.ComponentModel.ISynchronizeInvoke SynchronizingObject = default)
 {
     Watcher = new System.IO.FileSystemWatcher()
     {
         Path                = Path,
         Filter              = Filter,
         NotifyFilter        = NotifyFilters,
         SynchronizingObject = SynchronizingObject,
     };
     if (Changed != null)
     {
         Watcher.Changed += new System.IO.FileSystemEventHandler(Changed);
     }
     if (Created != null)
     {
         Watcher.Created += new System.IO.FileSystemEventHandler(Created);
     }
     if (Deleted != null)
     {
         Watcher.Deleted += new System.IO.FileSystemEventHandler(Deleted);
     }
     if (Renamed != null)
     {
         Watcher.Renamed += new System.IO.RenamedEventHandler(Renamed);
     }
     Watcher.EnableRaisingEvents = true;
 }
        private FileSystemWatcherBase CreateFileSystemWatcher(NotifyFilters notifyFilter)
        {
            var watcher = _fileSystem.FileSystemWatcher.Create(_directory, _filter);

            watcher.EnableRaisingEvents   = true;
            watcher.IncludeSubdirectories = true;
            watcher.InternalBufferSize    = 65536;
            watcher.NotifyFilter          = notifyFilter;
            return(watcher);
        }
Exemple #3
0
 public static async Task StartAsync(CancellationToken Token, Action <object, System.IO.FileSystemEventArgs> Changed = default, Action <object, System.IO.FileSystemEventArgs> Created = default, Action <object, System.IO.FileSystemEventArgs> Deleted = default, Action <object, System.IO.RenamedEventArgs> Renamed = default
                                     , string Path = default, string Filter = default, System.IO.NotifyFilters NotifyFilters = default, System.ComponentModel.ISynchronizeInvoke SynchronizingObject = default)
 {
     try
     {
         using (new DirectoryWatcher(Changed, Created, Deleted, Renamed, Path, Filter, NotifyFilters, SynchronizingObject))
             await Task.Delay(Timeout.Infinite, Token);
     }
     catch (ObjectDisposedException) { }
     catch (TaskCanceledException) { }
 }
Exemple #4
0
 public static Task StartAsync(CancellationToken Token, Action <object, System.IO.FileSystemEventArgs> Changed = default, Action <object, System.IO.RenamedEventArgs> Renamed = default
                               , string Path = default, string Filter = default, System.IO.NotifyFilters NotifyFilters = default, System.ComponentModel.ISynchronizeInvoke SynchronizingObject = default)
 => StartAsync(Token, Changed, Changed, Changed, Renamed, Path, Filter, NotifyFilters, SynchronizingObject);
Exemple #5
0
 public DirectoryWatcher(Action <object, System.IO.FileSystemEventArgs> Changed = default, Action <object, System.IO.RenamedEventArgs> Renamed = default
                         , string Path = default, string Filter = default, System.IO.NotifyFilters NotifyFilters = default, System.ComponentModel.ISynchronizeInvoke SynchronizingObject = default)
     : this(Changed, Changed, Changed, Renamed, Path, Filter, NotifyFilters, SynchronizingObject)
 {
 }