[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 325
  • Last Modified:

Stopping a FileSystemWatcher

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)

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

    End Sub

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

How can I stop the watch
0
DigitalDan3
Asked:
DigitalDan3
  • 2
1 Solution
 
Jens FiedererCommented:
Set the EnableRaisingEvents property to false.
0
 
DigitalDan3Author Commented:
I feel stupid.

That was too easy.

Dan
0
 
Jens FiedererCommented:
I don't mind :-)
0

Featured Post

Technology Partners: 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!

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now