Пример #1
0
        private void RegisterDirectoryWatcher(string path)
        {
            DirectoryWatcher directoryWatcher = new DirectoryWatcher(path, OnFileEvent, OnError);

            directoryWatcher.Start();

            DirectoryWatchers.Add(path, directoryWatcher);
        }
Пример #2
0
        public static void RegisterDirectoryWatcher(string path)
        {
            DirectoryWatcher directoryWatcher = new DirectoryWatcher(path, OnFileEvent, OnError);

            directoryWatcher.Start();

            if (DirectoryWatchers.ContainsKey(path))
            {
                DirectoryWatchers[path].Stop();
                DirectoryWatchers.Remove(path);
            }

            DirectoryWatchers.Add(path, directoryWatcher);
        }