Here's a great little sample of FileSystemWatcher from Roy Osherove. Tank God for anonymous delegates :)
FileSystemWatcher watcher = new FileSystemWatcher("c:\\");
watcher.IncludeSubdirectories = true;
watcher.Changed+=delegate(object sender, FileSystemEventArgs e)
{
string file = Path.GetFileName(e.FullPath);
string dir = Path.GetDirectoryName(e.FullPath);
...
}
};
watcher.EnableRaisingEvents = true;
No comments:
Post a Comment