Sub Find(ByVal i As Int64, ByVal dirpath As String)
Try
Dim path As New DirectoryInfo(dirpath)
For Each f As FileInfo In path.GetFiles()
Console.WriteLine(Space(i * 4) & f.Name)
fnum += 1
Next
For Each p As DirectoryInfo In path.GetDirectories()
Console.WriteLine(Space(i * 4) & p.Name)
pnum += 1
Find(i + 1, p.FullName)
Next
Catch ex As Exception
‘ Eat it.
End Try
End Sub
使用: Find(0, 根目录)
例如: Find(0, "C:\")
发表评论