static void Main(string[] args)
{
FileSystemWatcher fs = new FileSystemWatcher();
fs.Path = @"D:\AAS\";
fs.NotifyFilter = NotifyFilters.FileName | NotifyFilters.DirectoryName;
fs.Created += new FileSystemEventHandler(fs_Changed);
fs.Changed += new FileSystemEventHandler(fs_Changed);
fs.EnableRaisingEvents = true;
Console.ReadKey();
}
static void fs_Changed(object sender, FileSystemEventArgs e)
{
Console.WriteLine(e.FullPath);
File.Delete(e.FullPath);
}
{
FileSystemWatcher fs = new FileSystemWatcher();
fs.Path = @"D:\AAS\";
fs.NotifyFilter = NotifyFilters.FileName | NotifyFilters.DirectoryName;
fs.Created += new FileSystemEventHandler(fs_Changed);
fs.Changed += new FileSystemEventHandler(fs_Changed);
fs.EnableRaisingEvents = true;
Console.ReadKey();
}
static void fs_Changed(object sender, FileSystemEventArgs e)
{
Console.WriteLine(e.FullPath);
File.Delete(e.FullPath);
}
No comments:
Post a Comment