FileSystemWatcher Exclude File Type

Posted on 2005-04-26
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
    LVL 96

    Expert Comment

    by:Bob Learned
    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

    TheLearnedOne -

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

    Accepted Solution

     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

    TheLearnedOne  -

    Perfect - thanks!!!!!!

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    What Is Threat Intelligence?

    Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

    Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
    It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
    This video is in connection to the article "The case of a missing mobile phone (". It will help one to understand clearly the steps to track a lost android phone.
    Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

    760 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

    Need Help in Real-Time?

    Connect with top rated Experts

    8 Experts available now in Live!

    Get 1:1 Help Now