Stopping a FileSystemWatcher

Posted on 2006-03-29
Last Modified: 2012-06-21
I have an application inwhich I have a button that starts a file system watcher.  

 Private Watch As New System.IO.FileSystemWatcher

Form Load
         AddHandler Watch.Created, AddressOf Watch_Created

My button Click calls StartWatch

    Private Sub StartWatch(ByVal DirectoryPath As String)

            'Watch.Path = ConfigOpt.GetOption("SpoolDirectory")
            Watch.Path = DirectoryPath
            Watch.Filter = "*.txt"
            Watch.IncludeSubdirectories = False
            Watch.EnableRaisingEvents = True
            MessageBox.Show("Watch Created")
        Catch ex As Exception
        End Try

    End Sub

    Private Sub Watch_Created(ByVal sender As Object, ByVal e As System.IO.FileSystemEventArgs)
    End Sub

How can I stop the watch
Question by:DigitalDan3
    LVL 23

    Accepted Solution

    Set the EnableRaisingEvents property to false.

    Author Comment

    I feel stupid.

    That was too easy.

    LVL 23

    Expert Comment

    by:Jens Fiederer
    I don't mind :-)

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Join & Write a Comment

    Introduction When many people think of the WebBrowser ( control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
    Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
    Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
    Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

    745 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

    16 Experts available now in Live!

    Get 1:1 Help Now