Additional parameters for FileSystemEventHandler
Posted
by peku
on Stack Overflow
See other posts from Stack Overflow
or by peku
Published on 2010-04-14T09:24:49Z
Indexed on
2010/04/14
9:43 UTC
Read the original article
Hit count: 209
c#
|filesystemwatcher
I'm trying to write a program that could monitor multiple folders for file creations and launch the same action but with different settings for each folder. My problem is in specifying an extra parameter for the FileSystemEventHandler. I create a new FileWatcher for each directory to monitor and add the handler for the 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);
}
How could I get the 'mSettings' variable passed to FileSystemWatcherCreated()?
© Stack Overflow or respective owner