beefeater267
Programmer
- Apr 6, 2005
- 79
Hi, I need to create a filesystemwatcher at runtime based on entries in XML document. However, it does not seem to work. (The event NEVER fires). Can anyone help me out w/ what is wrong w/ this code?
I have a function that does the following code:
//loop through our Watcher Nodes
private void CreateFSWs()
{
for (int k=0; k<fileWatcherNodes.Count; k++)
{
fileWatcherNode = fileWatcherNodes[k];
lookDirectory = @"C:";
fsw = new FileSystemWatcher(lookDirectory);
((System.ComponentModel.ISupportInitialize)(fsw)).BeginInit();
fsw.EnableRaisingEvents = true;
fsw.SynchronizingObject = this;
fsw.Changed+=new FileSystemEventHandler(fsw_Changed);
fsw.SynchronizingObject = this;
}
}
private void fsw_Changed(object sender, FileSystemEventArgs e)
{
string x = "";
}
Anybody know what is wrong w/ this? Can anyone maybe provide a sample of a FSW created a runtime that has this Changed event that fires?
Thanks a million
I have a function that does the following code:
//loop through our Watcher Nodes
private void CreateFSWs()
{
for (int k=0; k<fileWatcherNodes.Count; k++)
{
fileWatcherNode = fileWatcherNodes[k];
lookDirectory = @"C:";
fsw = new FileSystemWatcher(lookDirectory);
((System.ComponentModel.ISupportInitialize)(fsw)).BeginInit();
fsw.EnableRaisingEvents = true;
fsw.SynchronizingObject = this;
fsw.Changed+=new FileSystemEventHandler(fsw_Changed);
fsw.SynchronizingObject = this;
}
}
private void fsw_Changed(object sender, FileSystemEventArgs e)
{
string x = "";
}
Anybody know what is wrong w/ this? Can anyone maybe provide a sample of a FSW created a runtime that has this Changed event that fires?
Thanks a million