我有一个带有两个EventHandler的简单FileSystemWatcher。如果设置断点我看到EventHandler被激活,但MessageBox从不显示。我做错了什么?
fw.NotifyFilter = NotifyFilters.FileName | NotifyFilters.Size;
fw.EnableRaisingEvents = true;
fw.Created += new FileSystemEventHandler(Watcher_Created);
fw.Changed += new FileSystemEventHandler(Watcher_Changed);
EventHandler:
public void Watcher_Created(object source, FileSystemEventArgs inArgs)
{
System.Windows.MessageBox.Show("Created");
}
public void Watcher_Changed(object sender, FileSystemEventArgs inArgs)
{
System.Windows.MessageBox.Show("Created");
}