我正在嘗試編寫一個程序,該程序可以監視文件創建的多個文件夾,並針對每個文件夾啓動相同的操作但具有不同的設置。我的問題是在爲FileSystemEventHandler指定一個額外的參數。我創建了一個新的FileWatcher每個目錄監控和添加的處理程序中創建行動:FileSystemEventHandler的其他參數
foreach (String config in configs)
{
...
FileWatcher.Created += new System.IO.FileSystemEventHandler(FileSystemWatcherCreated)
...
}
void FileSystemWatcherCreated(object sender, System.IO.FileSystemEventArgs e, MySettings mSettings)
{
DoSomething(e.FullPath, mSettings);
}
我怎麼能得到()的「mSettings」變量傳遞給FileSystemWatcherCreated?
哪裏'mSettings'被置? – James 2010-04-14 09:35:05
對不起,這個不好的例子。 mSettings被設置在第一個...從當前的配置中,但我認爲它並不真正與問題相關。 – peku 2010-04-14 10:02:41