FileSystemWatcher
n FileSystemWatcher Is Used to Monitor a File System
n Creating a FileSystemWatcher Object
n
n Configure
n
n
n
n Begin Watching
n
n Catch Events
FileSystemWatcher watcher = new FileSystemWatcher();
watcher.Path = args[0];
watcher.Filter = "*.txt";
watcher.NotifyFilter = NotifyFilters.FileName;
watcher.Renamed += new
RenamedEventHandler(OnRenamed);
watcher.EnableRaisingEvents = true;
public static void OnRenamed(object s, RenamedEventArgs e) {
Console.WriteLine("File: {0} renamed to {1}",
e.OldFullPath, e.FullPath); }