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工作。 –