fw.Created += new FileSystemEventHandler(fw_Created); fw.Deleted += new FileSystemEventHandler(fw_Deleted); fw.EnableRaisingEvents = true; } void fw_Deleted(object sender, FileSystemEventArgs e) { throw new Exception("The method or operation is not implemented."); }
DirWatch dw = new DirWatch();
dw.Initial();DirWatch类是在app_code文件夹下
void Watch()
{
FileSystemWatcher fw = new FileSystemWatcher(dir);
fw.NotifyFilter = NotifyFilters.FileName | NotifyFilters.DirectoryName | NotifyFilters.LastAccess | NotifyFilters.LastWrite;
fw.Created += new FileSystemEventHandler(fw_Created);
fw.Deleted += new FileSystemEventHandler(fw_Deleted);
fw.EnableRaisingEvents = true;
} void fw_Deleted(object sender, FileSystemEventArgs e)
{
throw new Exception("The method or operation is not implemented.");
}
加了fw.Changed += new FileSystemEventHandler(fw_Changed);也没用
我觉得可以单独写个服务程序
然后在Application_Start启动这个服务