473,387 Members | 1,483 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

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
1 1904
bukkko
1
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

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

Similar topics

0
by: yasir | last post by:
I am using Watcher to detect any file renamed event. From time to time, or when lot of files gets renamed at the same time, Watcher fails to detect some files. I have set the InternalBuffereSize to...
0
by: Jack David | last post by:
I am using the following code to monitor a directory for new files. The problem is that when I add a new file to the directory the code creates two events??? what do I have to do to limit it to...
5
by: ToddT | last post by:
i've got one app that writes large files to a specific directory that is watched by another app via an instance of the file system watcher class. my problem is that the second app is notified when...
1
by: Stuart Ferguson | last post by:
I am currently writing a Windows service which monitors multiple folders and processes the files in them accordingly. The folders to be monitored are stored in a string array. I can think of 2...
0
by: test | last post by:
Hi, I have the following method: private void fileSystemWatcher1_Created(object sender, System.IO.FileSystemEventArgs e) { string tmpPath = e.FullPath; tmpPath = tmpPath.Replace("\\",...
0
by: Brian Henry | last post by:
I wrote an application that interacts with the file system watcher in a windows service.. what it does is copies a file that was moved into a specific folder into another upon creation in that...
0
by: Shane Story | last post by:
I have a file system watcher. It is watching one directory where faxes come in. These faxes are written by another software program. The create event seems to fire and then we get an error...
2
by: Jason | last post by:
hi, i have an application that has a filesystemwatcher if this app is running...and the user attempts to shut the pc down (or log off) nothing happens.... if the program is stopped the user...
0
by: stephen | last post by:
Hi, I am using File System Watcher to Monitor a folder and users write reports to the folder (Excel word documents etc...). I am creating a log file to tracking information written to the...
6
by: =?Utf-8?B?UmV5bm9sZHNVc2Vy?= | last post by:
Hello - My question involves using a FileSystemWatcher class within threads in a process. I am starting multiple threads, and launching a method I called "Start" for each; within each thread, I...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.