C#监控指定目录的文件变化的代码
如下的资料是关于C#监控指定目录的文件变化的代码。
FileSystemWatcher watcher = new FileSystemWatcher();
watcher.Path = @"c:mydir";
watcher.Created += new FileSystemEventHandler(watcher_Changed);
watcher.Deleted += new FileSystemEventHandler(watcher_Changed);
watcher.EnableRaisingEvents = true;
static void watcher_Changed(object sender,FileSystemEventArgs e)
{
Console.WriteLine("Directory changed({0}): {1}",
e.ChangeType,
e.FullPath);
}