【发布时间】:2023-03-29 11:45:02
【问题描述】:
我正在尝试编写一个程序,该程序可以监视多个文件夹的文件创建并启动相同的操作,但每个文件夹的设置不同。我的问题是为 FileSystemEventHandler 指定一个额外的参数。我为每个目录创建一个新的 FileWatcher 来监视和添加 Created-action 的处理程序:
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在哪里设置? -
抱歉这个不好的例子。 mSettings 是在当前配置的第一个...中设置的,但我认为它与问题并不真正相关。
标签: c# filesystemwatcher