我正在尝试监视文件夹(及其子文件夹)的更改。但是,我的处理程序事件从未执行。我正在使用以下代码:

FileSystemWatcher m_Watcher = new FileSystemWatcher();
m_Watcher.Path = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "/Portal 2 Map Installer/";
m_Watcher.Filter = "";
m_Watcher.NotifyFilter = NotifyFilters.LastAccess |
             NotifyFilters.LastWrite |
             NotifyFilters.FileName |
             NotifyFilters.DirectoryName;
m_Watcher.IncludeSubdirectories = true;
m_Watcher.Changed += new FileSystemEventHandler(OnFolderChange);
m_Watcher.EnableRaisingEvents = true;


请帮忙!

最佳答案

为错误事件创建处理程序,然后查看其内容:

  m_Watcher.Error += new ErrorEventHandler(OnError);

09-07 02:03