文件名称:C# 如何监视文件变化的各事件
文件大小:4KB
文件格式:TXT
更新时间:2014-08-04 05:03:36
文件监视 变化
FileSystemWatcher watcher = new FileSystemWatcher(); // 如果改为 *.txt 等,就不能监视目录的变化 watcher.Filter = "*.*"; watcher.IncludeSubdirectories = true; watcher.Path = @"D:\"; watcher.Changed += new FileSystemEventHandler(OnChanged); watcher.Created += new FileSystemEventHandler(OnChanged); watcher.Deleted += new FileSystemEventHandler(OnChanged); watcher.Renamed += new RenamedEventHandler(OnFileRenamed);