473,545 Members | 1,863 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Howto: Regex & FileSystemWatch er Filter

How can I (can I?) use a regular expression as the filter to a
FileSystemWatch er?

I want to watch for something like this:

Regex regex = new Regex(@"^Curren t(One|Two|Three )File\.txt$",
RegexOptions.Ig noreCase);

That is, is the file CurrentOneFile. txt, CurrentTwoFile. txt, etc. shows in
in the directory I'm watching, then I can take action.

I can't assign the regex to the filter though:

FileSystemWatch er fsw = new FileSystemWatch er ();
fsw.Filter = regex; // won't work
How can I accomplish this?

TIA

Jul 21 '05 #1
1 5869
If you read the docs it accepts only a string. You will have to get all
watch for all *.txt and then apply the regex to any file changes you are
notified of. For what you are doing a regex might be a little heavy for the
file name comparison.

Lloyd Sheen
"Shmulik" <sh*******@yaho o.com> wrote in message
news:ec******** ******@TK2MSFTN GP12.phx.gbl...
How can I (can I?) use a regular expression as the filter to a
FileSystemWatch er?

I want to watch for something like this:

Regex regex = new Regex(@"^Curren t(One|Two|Three )File\.txt$",
RegexOptions.Ig noreCase);

That is, is the file CurrentOneFile. txt, CurrentTwoFile. txt, etc. shows in in the directory I'm watching, then I can take action.

I can't assign the regex to the filter though:

FileSystemWatch er fsw = new FileSystemWatch er ();
fsw.Filter = regex; // won't work
How can I accomplish this?

TIA

Jul 21 '05 #2

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

Similar topics

0
2445
by: Peter Valdemar M?rch | last post by:
Hi, In short, how to modify selected tags/sections of a HTML file, using PHP as the "modifier"/filter? I would have thought this was a very common usage for PHP... I have a set of existing .html files that are plain and ugly. I'd like to create a showdoc.php filter that adds consistent menus, css, look and feel, so that...
0
328
by: John | last post by:
Is there a way to watch more than 1 extension? The default filter is *.* (watch all files with an extension). How do I set it so I can have *.txt and *.dll monitor? Thanks
2
4734
by: Ian Frawley | last post by:
anyone know how to filter different file types ie .jpg .gif in FileSystemWatcher.Filter? Ian -- "Life should NOT be a journey to the grave with the intention of arriving safely in an attractive and well preserved body, but rather to skid in sideways,
1
327
by: Shmulik | last post by:
How can I (can I?) use a regular expression as the filter to a FileSystemWatcher? I want to watch for something like this: Regex regex = new Regex(@"^Current(One|Two|Three)File\.txt$", RegexOptions.IgnoreCase); That is, is the file CurrentOneFile.txt, CurrentTwoFile.txt, etc. shows in in the directory I'm watching, then I can take...
4
3593
by: shonend | last post by:
I am trying to extract the pattern like this : "SUB: some text LOT: one-word" Described, "SUB" and "LOT" are key words; I want those words, everything in between and one word following the "LOT:". Source text may contain multiple "SUB: ... LOT:" blocks. For example this is my source text:
3
9790
by: emailtonitin | last post by:
I am facing a design issue in my code related to the filesystemwatcher's filter property. I figured out that the filter won't accept multiple patterns for eg. "*.txt, *.csv" don't work. To workaround this issue, I have 2 options: 1. To create multiple instances of filesystemwatcher class and hook all of them to the same event handlers. 2....
4
4377
by: hooksie2 | last post by:
Hi, I am trying to use FileSystemWatcher to watch a log file which is written to via a 3rd party app and display the log in listbox on a form. The FileSystemWatch seems to work okay but I get the following error when I try to write to the listbox: "A first chance exception of type 'System.ArgumentNullException' occurred in...
0
1156
by: Wilson799799 | last post by:
Hello, I am searching for a way to match quotation marks (extended ascii characters 147 and 148) with a .net regex. I tried this regex += .... |" + System.Convert.ToChar(147) + "|" + System.Convert.ToChar(148) + |\w+|)" but the convert yields an empty string. I cannot use the dot operator for this regex. Thank you.
4
2853
by: Twayne | last post by:
Hi, I've been playing with ' if(!filter_var($email, FILTER_VALIDATE_EMAIL)) ' on my server and it seems to be working 100%. Pretty handy. Any ideas where I could find a summary of the e-mail formats the filter checks? So far it's evading me. The Manual and w3schools just send me in
0
7487
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7420
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7680
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7934
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
7778
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
3476
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3459
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1908
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
731
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.