home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic .NET - Read Less - Learn More / Visual_Basic.NET_Read_Less_Learn_More_Richard_Bowman_Visual_2002.iso / Resources / Code / Ch5-WatchFileSysChanges / Form1.vb < prev   
Text File  |  2001-07-19  |  3KB  |  80 lines

  1. Public Class Form1
  2.     Inherits System.Windows.Forms.Form
  3.  
  4. #Region " Windows Form Designer generated code "
  5.  
  6.     Public Sub New()
  7.         MyBase.New()
  8.  
  9.         'This call is required by the Windows Form Designer.
  10.         InitializeComponent()
  11.  
  12.         'Add any initialization after the InitializeComponent() call
  13.  
  14.     End Sub
  15.  
  16.     'Form overrides dispose to clean up the component list.
  17.     Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
  18.         If disposing Then
  19.             If Not (components Is Nothing) Then
  20.                 components.Dispose()
  21.             End If
  22.         End If
  23.         MyBase.Dispose(disposing)
  24.     End Sub
  25.     Friend WithEvents ListBox1 As System.Windows.Forms.ListBox
  26.     Friend WithEvents FileSystemWatcher1 As System.IO.FileSystemWatcher
  27.  
  28.     'Required by the Windows Form Designer
  29.     Private components As System.ComponentModel.Container
  30.  
  31.     'NOTE: The following procedure is required by the Windows Form Designer
  32.     'It can be modified using the Windows Form Designer.  
  33.     'Do not modify it using the code editor.
  34.     <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
  35.         Me.ListBox1 = New System.Windows.Forms.ListBox()
  36.         Me.FileSystemWatcher1 = New System.IO.FileSystemWatcher()
  37.         CType(Me.FileSystemWatcher1, System.ComponentModel.ISupportInitialize).BeginInit()
  38.         Me.SuspendLayout()
  39.         '
  40.         'ListBox1
  41.         '
  42.         Me.ListBox1.HorizontalScrollbar = True
  43.         Me.ListBox1.Location = New System.Drawing.Point(40, 32)
  44.         Me.ListBox1.Name = "ListBox1"
  45.         Me.ListBox1.Size = New System.Drawing.Size(216, 160)
  46.         Me.ListBox1.TabIndex = 0
  47.         '
  48.         'FileSystemWatcher1
  49.         '
  50.         Me.FileSystemWatcher1.EnableRaisingEvents = True
  51.         Me.FileSystemWatcher1.NotifyFilter = ((System.IO.NotifyFilters.FileName Or System.IO.NotifyFilters.DirectoryName) _
  52.                     Or System.IO.NotifyFilters.LastWrite)
  53.         Me.FileSystemWatcher1.Path = "C:\"
  54.         Me.FileSystemWatcher1.SynchronizingObject = Me
  55.         '
  56.         'Form1
  57.         '
  58.         Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
  59.         Me.ClientSize = New System.Drawing.Size(292, 273)
  60.         Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.ListBox1})
  61.         Me.Name = "Form1"
  62.         Me.Text = "Form1"
  63.         CType(Me.FileSystemWatcher1, System.ComponentModel.ISupportInitialize).EndInit()
  64.         Me.ResumeLayout(False)
  65.  
  66.     End Sub
  67.  
  68. #End Region
  69.  
  70.     Private Sub FileSystemWatcher1_Changed(ByVal sender As System.Object, ByVal e As System.IO.FileSystemEventArgs) Handles FileSystemWatcher1.Changed
  71.         ListBox1.Items.Add(e.Name & " - " & _
  72.             e.ChangeType.ToString())
  73.     End Sub
  74.  
  75.     Private Sub FileSystemWatcher1_Created(ByVal sender As Object, ByVal e As System.IO.FileSystemEventArgs) Handles FileSystemWatcher1.Created
  76.         ListBox1.Items.Add(e.Name & " - " & _
  77.             e.ChangeType.ToString())
  78.     End Sub
  79. End Class
  80.