public DirectoryWatcher(string path, string wildCard) { queue = new Helper.ThreadSafeQueue<FileSystemEventArgs>(); watcher = new FileSystemWatcher(); Action<object, FileSystemEventArgs> h = (s, e) => { queue.Enqueue(e); }; watcher.Path = path; watcher.Filter = wildCard; watcher.NotifyFilter = NotifyFilters.LastWrite; watcher.Created += new FileSystemEventHandler(h); watcher.Deleted += new FileSystemEventHandler(h); watcher.Changed += new FileSystemEventHandler(h); watcher.EnableRaisingEvents = true; }
public DirectoryWatcher(string path, string wildCard) { queue = new Helper.ThreadSafeQueue <FileSystemEventArgs>(); watcher = new FileSystemWatcher(); Action <object, FileSystemEventArgs> h = (s, e) => { queue.Enqueue(e); }; watcher.Path = path; watcher.Filter = wildCard; watcher.NotifyFilter = NotifyFilters.LastWrite; watcher.Created += new FileSystemEventHandler(h); watcher.Deleted += new FileSystemEventHandler(h); watcher.Changed += new FileSystemEventHandler(h); watcher.EnableRaisingEvents = true; }