Watch for file system changes

oka

New member
Joined
Jul 14, 2006
Messages
3
Programming Experience
Beginner
VB.NET:
Public Class Form1
    Inherits System.Windows.Forms.Form


    Private Sub FileSystemWatcher1_Changed(ByVal sender As System.Object, ByVal e As System.IO.FileSystemEventArgs) Handles FileSystemWatcher1.Changed
        ListBox1.Items.Add(e.Name & " - " & _
        e.ChangeType.ToString())
    End Sub

    Private Sub FileSystemWatcher1_Created(ByVal sender As System.Object, ByVal e As System.IO.FileSystemEventArgs) Handles FileSystemWatcher1.Changed
        ListBox1.Items.Add(e.Name & " - " & _
        e.ChangeType.ToString())
    End Sub

    
    
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    End Sub
End Class
In the output form that is displayed only listbox seems to appear. There is nothing inside the listbox. In the book there is some text displayed inside the listbox. but for me it does not show :eek:. please help me.
 
Did you set the folder Path to monitor? Did you try to create a new file there? Made sure EnableRaisingEvents (that's the on/off switch) is True? Is the Filter still default *.*?
 
Look at the Handles clauses. Both you event handlers are handling the Changed event. Neither are handling the Created event. That's the advantage of having a wide monitor. I could see the handles clauses. :)
 
That still doesn't explain why oka isn't getting any Changed events..
 
Back
Top