Just sharing some of my inconsequential lunch conversations with you... RSS  

Friday, July 13, 2007

FileSystemWatcher

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:

Development Catharsis :: Copyright 2006 Mário Romano