FileSystemWatcher Exclude File Type

Posted on 2005-04-26
Medium Priority
Last Modified: 2012-05-07
I have a simple filesystemwatcher and want to exclude all .log file types - any examples would be great!!!
Question by:tbaseflug
  • 2
  • 2
LVL 96

Expert Comment

by:Bob Learned
ID: 13866447
Are you looking for *.*, with the exception of *.log?

The FileSystemWatcher.Filter property can filter one type, but if you are looking to get everything but .log files, then you can use an If...Then block within the event to skip processing any file types with that extension using the System.IO.Path.GetExtension method.


Author Comment

ID: 13866500
TheLearnedOne -

That is exactly what I am lookign to do - can you provide me with a quick sample of code?
LVL 96

Accepted Solution

Bob Learned earned 2000 total points
ID: 13866531
 Private Sub FileSystemWatcher1_Changed(ByVal sender As System.Object, ByVal e As System.IO.FileSystemEventArgs) Handles FileSystemWatcher1.Changed

    If System.IO.Path.GetExtension(e.FullPath).ToLower <> ".log" Then

    End If

  End Sub


Author Comment

ID: 13866556
TheLearnedOne  -

Perfect - thanks!!!!!!

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
Suggested Courses
Course of the Month13 days, 16 hours left to enroll

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question