簡體   English   中英

FileSystemWatcher Changed事件不會觸發

[英]FileSystemWatcher Changed event doesn't fire

FileSystemWatcher fsw = new FileSystemWatcher();
fsw.Path = @"C:\foo.txt";
fsw.Changed += new FileSystemEventHandler(LogFileChanged);

private void LogFileChanged(object s, FileSystemEventArgs e)
{ 

}

如果我在LogFileChanged()打開一個斷點 - >打開並編輯foo.txt - >保存文件,則斷點不會命中。 有人能解釋我錯過了什么嗎?

這是一個文件而不是路徑

fsw.Path = @"C:\foo.txt";

你需要設置

fsw.Path = @"C:\";
fsw.Filter = "foo.txt";

過濾屬性

你有這個屬性嗎?

 fsw.EnableRaisingEvents = true;

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM