示例#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);
        }