vb.net监控路径上的任一文件夹,当重命名时触发事件。
发布网友
发布时间:2022-05-25 16:20
我来回答
共1个回答
热心网友
时间:2023-11-18 01:37
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
FileSystemWatcher1.NotifyFilter = IO.NotifyFilters.DirectoryName Or IO.NotifyFilters.FileName‘监控文件夹和文件。
FileSystemWatcher1.IncludeSubdirectories = True’监控子文件夹
End Sub
Private Sub FileSystemWatcher1_Renamed(sender As Object, e As IO.RenamedEventArgs) Handles FileSystemWatcher1.Renamed
MsgBox(e.FullPath & vbCrLf & e.Name)
End Sub'捕获新路径
你监控test不就好了,若要排除其他文件夹,IncludeSubdirectories 设为假,用多个FileSystemWatcher就行了,用数组或其他方式创建。来自:求助得到的回答