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;
        }
Ejemplo n.º 2
0
        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;
        }