何以笙箫默学生许影:VB.NET 高手请进

来源:百度文库 编辑:高校问答 时间:2024/05/04 17:43:45
在 VB.NET 中自定义了一个 Sub 过程,内容如下:

Private Sub ListFile(ByVal Path As String)
On Error Resume Next
Dim i, j As String
For Each i In My.Computer.FileSystem.GetFiles(Path)
Dim ext As String = My.Computer.FileSystem.GetFileInfo(i).Extension
ext = Microsoft.VisualBasic.LCase(ext)
If ext = ".tmp" Or ext = ".chk" Or ext = ".ftg" Or ext = ".fts" Or ext = ".gid" _
Or ext = ".old" Or ext = ".prv" Or ext = ".prv" Or ext = ".err" Or ext = ".syd" _
Or ext = ".diz" Or ext = ".dmp" Then
CheckedListBox2.Items.Add(i.ToString)
End If
Next
For Each j In My.Computer.FileSystem.GetDirectories(Path)
ListFile(j)
Next
My.Application.DoEvents()
End Sub

当我调用 ListFile("C:\") 或者 ListFile("D:\") 时一切正常但是用于 E:\ F:\ G:\ 就会出错。
我的 C、D 的文件系统是 Fat32 ,E、F、G 是 NTFS,难道跟这个有关吗?正确的写法应该是怎样?

NTFS系统下,只有SYSTEM用户才能访问System Volume Information 目录,所以导致错误。

对。列目录的时候需要把System Volume Information文件夹过滤掉