Foxtable(狐表)用户栏目专家坐堂 → FileSystemWatcher 怎么停止监控


  共有2012人关注过本帖树形打印复制链接

主题:FileSystemWatcher 怎么停止监控

帅哥哟,离线,有人找我吗?
有点蓝
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:超级版主 帖子:106178 积分:540007 威望:0 精华:9 注册:2015/6/24 9:21:00
  发帖心情 Post By:2019/2/22 20:18:00 [显示全部帖子]

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肯定都会触发一次

 回到顶部