public class FileWatcher{public FileWatcher(){string fpath = @"D:\MyFolder";//you can specify a file type or a specific filename as//the second parameter of FileSystemWatcher or *.* for all//type of filesFileSystemWatcher WatchFile = new FileSystemWatcher(fpath, "*.txt");WatchFile.Created += new FileSystemEventHandler(this.FileCreated);WatchFile.Renamed += new RenamedEventHandler(this.FileReNamed);WatchFile.Deleted += new FileSystemEventHandler(this.FileDeleted);WatchFile.EnableRaisingEvents = true;}

public void FileDeleted(object sender,FileSystemEventArgs e){Console.WriteLine(e.ToString());}static void Main(string[] args){FileWatcher fw = new FileWatcher();//sits idle and watches for any creation,renaming//or deletion of file best use of this program is//to run it as a windows service.Console.ReadLine();}}