Sto provando a scrivere un programma in grado di monitorare più cartelle per le creazioni di file e avviare la stessa azione ma con impostazioni diverse per ogni cartella. Il mio problema è nello specificare un parametro aggiuntivo per FileSystemEventHandler. Creo una nuova FileWatcher per ogni directory per monitorare e aggiungere il gestore per l'azione Creato:Parametri aggiuntivi per 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);
}
Come avrei potuto ottenere la variabile 'mSettings' passato a FileSystemWatcherCreated()?
dove viene 'mSettings' da impostare? – James
Ci scusiamo per il cattivo esempio. mSettings è impostato nel primo ... dalla configurazione corrente ma ho pensato che non fosse realmente pertinente alla domanda. – peku