1、把watcher 的定义发到全局代码
dim watcherList as List(of System.IO.FileSystemWatcher)
原来的调用
watcherList = new List(of System.IO.FileSystemWatcher)
For Each r As Row In Tables("表A").Rows
Dim watcher As new System.IO.FileSystemWatcher()
'监视路径
watcher.Path = r("第一列")
'监视子文件夹
watcher.IncludeSubDirectories=True
'重命名
addhandler watcher.Renamed, addressof watcher_Renamed
'addhandler watcher.Changed, addressof watcher_Changed
'addhandler watcher.Deleted, addressof watcher_Deleted
'addhandler watcher.Created, addressof watcher_Created
watcher.EnableRaisingEvents = true
watcherList.add(watcher)
Next
停用
for each watcher as System.IO.FileSystemWatcher in watcherList
watcher .EnableRaisingEvents = False
net
2、什么文件?有些文件如word会生成几个临时文件的
其次定义的多个watcher监控的目录有没有交叉,如果有每个watcher肯定都会触发一次