I have a windows service that used a filesystemwatcher to monitor a directory, all worked fine. I am now trying to scale it to handle a few more watchers, depending on user input in a INI file.
The code i have the moment will read in the ini settings, and set the paths , it runs but the watchers never report I am trying this code below, but to no avail.
Any Ideas?. have I initialized them ok ?.
Also ClientFileUpdated just writes the event to eventviewer & filter set at ".*";
Expand|Select|Wrap|Line Numbers
- protected void CreateWatchers()
- {
- Logtext("Create Watchers");
- ArrayList fw = new ArrayList();
- foreach (string s in watchers)
- {
- MXFLOG.WriteEntry("For each loop");
- FileSystemWatcher Clientwatcher = new FileSystemWatcher();
- Clientwatcher.Path = s;
- Clientwatcher.Filter = FileFilter;
- Clientwatcher.NotifyFilter = NotifyFilters.LastWrite;
- Clientwatcher.Created += new FileSystemEventHandler(ClientFileUpdated);
- Clientwatcher.Changed += new FileSystemEventHandler(ClientFileUpdated);
- Clientwatcher.EnableRaisingEvents = true;
- fw.Add(Clientwatcher);
- }
- }