473,325 Members | 2,774 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,325 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 1501
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: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.