Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

FileSystemWatcher Problem

Status
Not open for further replies.

nikhilparchure

Programmer
Oct 6, 2001
121
AU
I am using FileSystemWatcher to monitor File movement in some File folders.
Have added some events to handle file/files added to that directory (Created).
The directory might contain file with different extensions
eg : .txt , .rtf , .doc , .xls
I would like the event to be fired only when ( .txt Or .rtf ) files are added to the directory.

The FileSystemWatcher has a property
FileSystemWatcher.Filter = ".extension" to watch particular extension.

To Watch all the files
FileSystemWatcher.Filter = "*.*"
which would filter the files that the watcher might be screening.

But I would like to have Single Watcher to monitor two type of files eg: .rtf Or .txt
I tried FileSystemWatcher.Filter = ".rtf , .txt" but this not work.

Any solution for the above problem.


Nikhil.....
 
You should create two FileSystemWatcher objects in this case. The both objects could be in the same thread or in different threads.
-obislavu-
 
Thanks for that....
Yaa thats true but can this be done using a single filesystemwatcher object.

I checkedout .NET help with regards to this , it says that the filter property follows "dir" comand format

With that respect if I want only .txt and .rtf files to be displayed than I use the [dir *.txt , *.rtf ] comand

So if the use the same in the Filter property it should work
But it doesn't
Thanks anyways

Nikhil
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top