This code sample sets up a handler to monitor the c:\ disk for changes in any file’s size, and report those changes to the console.
Imports System.IO Module Module1 ''' <summary> ''' Display the change events detected by the file system watcher on the console ''' </summary> ''' <param name="sender"></param> ''' <param name="e"></param> ''' <remarks></remarks> Private Sub DisplayChangeEvent(ByVal sender As Object, ByVal e As FileSystemEventArgs) Console.WriteLine("{0}{1} {2} ", e.FullPath, e.Name, e.ChangeType) End Sub ''' <summary> ''' Monitor the file system for changes, and report any changes in file size ''' until a random key is pressed. ''' </summary> ''' <remarks></remarks> Sub Main() ' --- Enlarge the console window for better reading Console.WindowHeight = 43 Console.WindowWidth = 132 ' // ' --- Setup the file system watcher Dim oWatcher As New FileSystemWatcher("c:\") oWatcher.IncludeSubdirectories = True ' oWatcher.Filter = "*.ini" oWatcher.NotifyFilter = NotifyFilters.Size AddHandler oWatcher.Changed, New FileSystemEventHandler(AddressOf DisplayChangeEvent) oWatcher.EnableRaisingEvents = True ' // ' --- Just idle in the loop handling events untill the user hits a key While Console.KeyAvailable = False System.Threading.Thread.Sleep(1) End While ' // End Sub End Modu