Public Sub SeachFile(ByVal strPath As String)
Dim Fso As Object
Dim Fol As Object
Dim Fil As Object
Set Fso = CreateObject("Scripting.FileSystemObject")
Set Fol = Fso.GetFolder(strPath)
For Each Fil In Fol.Files
Debug.Print Fil.Path '打印路径及文件名
Debug.Print Fil.Name '打印文件名
Next
For Each Fol In Fol.subfolders
Debug.Print Fol.Path '打印子目录的路径及名称
Debug.Print Fol.Name '打印子目录的名称
SeachFile Fol
Next
End Sub
Private Sub Command1_Click()
SeachFile ("C:\Test\")
End Sub