Filewatcher返回错误。没有重载匹配委托

时间:2010-09-17 13:35:52

标签: c#

我写过这个应该检查文件更改的方法。

public static void watch()    
   {    
        FileSystemWatcher watcher = new FileSystemWatcher();    
        watcher.Path = ConfigurationManager.AppSettings["OpticusFileLoc"];    
        watcher.Filter = "sigtrades.xml";    
        watcher.NotifyFilter = NotifyFilters.LastAccess | NotifyFilters.LastWrite
       | NotifyFilters.FileName | NotifyFilters.DirectoryName;    


       // watcher.Created += new FileSystemEventHandler(OnChanged);
        watcher.Changed += new FileSystemEventHandler(OnChanged);

        watcher.EnableRaisingEvents = true;

    }

但是,我收到此错误: “'OnChanged'没有重载匹配委托'System.IO.SystemEventHandler'

我哪里错了?

1 个答案:

答案 0 :(得分:3)

您的OnChanged方法需要the following signature

void OnChanged(object sender, FileSystemEventArgs e);

是吗?