예제 #1
0
파일: dsotfng.cs 프로젝트: Mnuzz/sc2dsstats
        private FileSystemWatcher MonitorDirectory(string path)
        {
            FileSystemWatcher fileSystemWatcher = new FileSystemWatcher();

            fileSystemWatcher.IncludeSubdirectories = false;
            fileSystemWatcher.Path                = path;
            fileSystemWatcher.Created            += new FileSystemEventHandler(FileSystemWatcher_Created);
            fileSystemWatcher.EnableRaisingEvents = true;
            if (WATCHER != null && !WATCHER.ContainsKey(path))
            {
                WATCHER.TryAdd(path, fileSystemWatcher);
            }
            fileSystemWatcher.WaitForChanged(WatcherChangeTypes.All);
            return(fileSystemWatcher);
        }
예제 #2
0
        private FileSystemWatcher MonitorDirectory(string path)
        {
            FileSystemWatcher fileSystemWatcher = new FileSystemWatcher(path);

            fileSystemWatcher.IncludeSubdirectories = false;
            //fileSystemWatcher.Path = path;

            fileSystemWatcher.NotifyFilter        = NotifyFilters.FileName | NotifyFilters.LastWrite;
            fileSystemWatcher.EnableRaisingEvents = true;

            //fileSystemWatcher.Created += FileSystemWatcher_Created;
            //fileSystemWatcher.Deleted += FileSystemWatcher_Deleted;
            fileSystemWatcher.Changed += FileSystemWatcher_Changed;
            //fileSystemWatcher.Renamed += FileSystemWatcher_Renamed;
            if (WATCHER != null && !WATCHER.ContainsKey(path))
            {
                WATCHER.TryAdd(path, fileSystemWatcher);
            }
            fileSystemWatcher.WaitForChanged(WatcherChangeTypes.All);
            return(fileSystemWatcher);
        }