static void Main(string[] args)
{
Watcher w = new Watcher();
w.watch(@"someLocation", (() => { MoveFiles.Move() ; return 0; }));
}
public void watch(string pathName, Func< int> OnChanged)
{
FileSystemWatcher watcher = new FileSystemWatcher();
watcher.Path = pathName;
watcher.Filter = "*.*";
watcher.Created += new FileSystemEventHandler(OnChanged);
watcher.EnableRaisingEvents = true;
Console.WriteLine("Press \'q\' to quit the sample.");
while (Console.Read() != 'q') ;
}
我试图通过OnChanged
事件定义为lambda表达式,但我得到传递事件处理程序的定义lambda表达式
Error: No Overload for Func matches the delegate "System.IO.FileSystemEventHandle"
我试图改变委托Func<int>
到Func<Object, FileSystemEventArgs, int>
但仍获得一些错误。
请指教。
谢谢you.It工作。 –