473,398 Members | 2,343 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,398 software developers and data experts.

FileSystemWatcher Class.. Filters?

The FileSystemWatcher Class has a filter property where you can tell it what
files you want it to watch for. I need it to watch for *.p** and *.f**
files both and have tried giving the filter the following strings
"*.p**;*.f**" and "*.p**,*.f**" and Each one on its own. Only when I supply
each one on its own does it pick up anything. My way around this was to
just use an if statement in the event triggers to look at the filename there
and drop it if its not what I want. I'm wondering if there is a better way?
Do I have the filter String Syntax wrong?

Ryan Rogers
Jul 21 '05 #1
1 1507
I think your main problem is your filter string is incorrect and you need to
create multiple FileSystemWatcher objects to achieve your goal. Here is
some sample code.

watcher1 = new FileSystemWatcher(Application.StartupPath);

watcher2 = new FileSystemWatcher(Application.StartupPath);

watcher1.Filter = "*.p*";

watcher2.Filter = "*.f*";

watcher1.EnableRaisingEvents = true;

watcher2.EnableRaisingEvents = true;

watcher1.Created += new FileSystemEventHandler(this.HandleFileCreatedEvent );

watcher2.Created += new FileSystemEventHandler(this.HandleFileCreatedEvent );

watcher1.Deleted += new FileSystemEventHandler(this.HandleFileDeletedEvent );

watcher2.Deleted += new FileSystemEventHandler(this.HandleFileDeletedEvent );
--
Jared Parsons [MSFT]
ja******@online.microsoft.com
This posting is provided "AS IS" with no warranties, and confers no rights.
OR if you wish to include a script sample in your post please add "Use of
included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm"

"Ryan Rogers" <ry*********@tesma.com> wrote in message
news:eG**************@TK2MSFTNGP09.phx.gbl...
The FileSystemWatcher Class has a filter property where you can tell it what files you want it to watch for. I need it to watch for *.p** and *.f**
files both and have tried giving the filter the following strings
"*.p**;*.f**" and "*.p**,*.f**" and Each one on its own. Only when I supply each one on its own does it pick up anything. My way around this was to
just use an if statement in the event triggers to look at the filename there and drop it if its not what I want. I'm wondering if there is a better way? Do I have the filter String Syntax wrong?

Ryan Rogers

Jul 21 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Ryan Rogers | last post by:
The FileSystemWatcher Class has a filter property where you can tell it what files you want it to watch for. I need it to watch for *.p** and *.f** files both and have tried giving the filter the...
1
by: eyal | last post by:
Hi, I'm trying to do this: private void SetNF(FileSystemWatcher fsw,int val){ if( (val&4)!=0 ) fsw.NotifyFilter |= System.IO.NotifyFilters.Attributes; // i'v tried this also: // if(...
3
by: Peter Kirk | last post by:
Hi I am trying to use FileSystemWatcher to watch for changes in a directory. The problem I am exepriencing is a double firing of an OnChanged event when a file is opened, edited, and saved. Why...
1
by: Terry | last post by:
I have created a Windows Service application which uses FileSystemWatcher to monitor multiple folders and file filters. These folders/files are loaded from a database table. When a Change Event...
20
by: J-T | last post by:
We are working on an asp.net application which is a 3-tier application.I was aksed to create a component which monitors a folder and gets the file and pass them to a class library in our business...
2
by: kmcnet | last post by:
Hello Everyone and thanks for your help in advance. I have been battling a problem for nearly a month with the FileSystemWatcher component. Basically, what I am trying to do it to monitor three...
0
by: Brett | last post by:
How can I do multiple file filters for the File watcher? This does work: watchfolder = New System.IO.FileSystemWatcher watchfolder.filter = "*.txt" This doesn't work: watchfolder.filter =...
1
by: SoxFan44 | last post by:
Hi, What's the best way to watch several directories (not sub dirs) with FileSystemWatcher? Should I create an array of them, vector, or something else? Also, performance-wise, how many...
4
by: tomb | last post by:
I'm using VB.net 2003 and a FileSystemWatcher. The Changed event gets called twice for every change in the folder I'm watching. To build the functionality, I'm manually changing a text file. As...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.