我FileSystemWatcher
在 Form1_Load 中添加如下:
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
....................
Dim watcher As New FileSystemWatcher()
'For watching current directory
watcher.Path = "/"
'For watching status.txt for any changes
watcher.Filter = "status.txt"
watcher.NotifyFilter = NotifyFilters.LastWrite
watcher.EnableRaisingEvents = True
AddHandler watcher.Changed, AddressOf OnChanged
End Sub
我有一个 OnChanged 函数,它是一个简单的 MessageBox。不过,当我更改status.txt
文件时,没有显示任何消息框。