467,886 Members | 1,807 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 467,886 developers. It's quick & easy.

File System Watcher problem referencing

I have this code to create multiple filesystemwatchers and store them in an array list but I need to be able to reference an individual watcher to disable raising events while I complete another process. Does anyone know how to achieve this?.

Thanks

Expand|Select|Wrap|Line Numbers
  1.  
  2.         protected void CreateWatchers()
  3.         {
  4.             Logtext("Create Watchers");
  5.  
  6.  
  7.             foreach (string s in watchers)
  8.             {
  9.  
  10.  
  11.                 System.IO.FileSystemWatcher Clientwatcher = new System.IO.FileSystemWatcher();
  12.  
  13.                 Clientwatcher.Path = s;
  14.  
  15.                 Clientwatcher.Filter = "*.FIDEF";
  16.  
  17.                 //Clientwatcher.NotifyFilter = NotifyFilters.
  18.  
  19.                 Clientwatcher.IncludeSubdirectories = false;
  20.  
  21.                 Clientwatcher.Created += new FileSystemEventHandler(FileWatcherUpdated);
  22.  
  23.                 //Clientwatcher.Changed += new FileSystemEventHandler(FileWatcherUpdated);
  24.  
  25.                 Clientwatcher.EnableRaisingEvents = true;
  26.  
  27.                 fw.Add(Clientwatcher);
  28.  
  29.  
  30.             }
  31.  
  32.  
Mar 22 '11 #1
  • viewed: 1732
Share:
1 Reply
Hi,

I'm trying to do something similar with multiple watchers.
did you ever find out how to do this?
Also I'd like to know where would you place the above code, as putting code in the InitializeComponent method is not allowed.

Thanks
Jan 11 '12 #2

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

reply views Thread by Jack David | last post: by
5 posts views Thread by ToddT | last post: by
1 post views Thread by Stuart Ferguson | last post: by
reply views Thread by test | last post: by
reply views Thread by Brian Henry | last post: by
reply views Thread by stephen | last post: by
6 posts views Thread by =?Utf-8?B?UmV5bm9sZHNVc2Vy?= | last post: by
reply views Thread by MrMoon | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.