FileSystemWatcher fsw = new FileSystemWatcher();
fsw.Path = @"C:\foo.txt";
fsw.Changed += new FileSystemEventHandler(LogFileChanged);
private void LogFileChanged(object s, FileSystemEventArgs e)
{
}
If i put a breakpoint in LogFileChanged()
-> open and edit foo.txt
-> saves the file, the breakpoint doesn't hit. Can someone explain what I missed?
This is a file not a path
fsw.Path = @"C:\foo.txt";
you need to set
fsw.Path = @"C:\";
fsw.Filter = "foo.txt";
你有这个属性吗?
fsw.EnableRaisingEvents = true;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.