本地驱动程序的文件系统观察程序 [英] File System Watcher for local driver

查看:91
本文介绍了本地驱动程序的文件系统观察程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好

我需要监控所有本地驱动程序,所以我编码这个

Hello
I need too monitor all local driver so I code this

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    Dim allDrives2() As IO.DriveInfo = IO.DriveInfo.GetDrives()
    Dim dd As IO.DriveInfo
    Dim N As Integer = 0
    Dim T(10) As FileSystemWatcher
    For Each dd In allDrives2
        If dd.IsReady = True Then
            T(N).Path = dd.Name
            T(N).IncludeSubdirectories = True
            T(N).EnableRaisingEvents = True
            N = N + 1
        End If
    Next
    
End Sub





把我弄错了!

有人可以改正吗?

谢谢



put I have error !
can someone correct it ?
Thank you

推荐答案

第一:

Dim T(10)As FileSystemWatcher

驱动器数量可能超过这个数量



第二名:

T (N)为null或Nothing,需要FileSystemWatcher的新实例



First:
Dim T(10) As FileSystemWatcher
The number of drives might more than that

Second:
T(N) is null or Nothing, new instance of FileSystemWatcher required

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    Dim allDrives2() As IO.DriveInfo = IO.DriveInfo.GetDrives()
    Dim N As Integer = 0
    Dim T(allDrives2.Length - 1) As IO.FileSystemWatcher
    For Each dd As IO.DriveInfo In allDrives2
        If dd.IsReady = True Then
            T(N) = New IO.FileSystemWatcher
            T(N).Path = dd.Name
            T(N).IncludeSubdirectories = True
            T(N).EnableRaisingEvents = True
            N += 1
        End If
    Next
End Sub


你有一个更大的问题。 FSW不是为了观看整个驱动器而设计的。你会遇到问题而错过活动。它也可能使用足够的资源来使系统爬行。



测试测试和更多测试!
You have a bigger problem. The FSW was not designed to watch an entire drive. You''ll have problems with it and miss events. It may also use enough resources to bring the system to a crawl.

Test TEST and MORE TEST!


这篇关于本地驱动程序的文件系统观察程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆