using System;
using System.IO;
public class Example15_9
{
// event handler for file change
public static void OnChanged(object source, FileSystemEventArgs e)
{
// dump info to the screen
Console.WriteLine("Change to " + e.FullPath + ": " +
e.ChangeType);
}
public static void Main()
{
// create a watcher for the c: drive
FileSystemWatcher fsw = new FileSystemWatcher("c:\\");
fsw.IncludeSubdirectories = true;
// hook up the event handler
fsw.Changed += new FileSystemEventHandler(OnChanged);
// turn on file watching
fsw.EnableRaisingEvents = true;
// And wait for the user to quit
Console.WriteLine("Press any key to exit");
int i = Console.Read();
}
}
|