Private Sub Command1_Click()
MyProc1 "d:\"
End Sub
Sub MyProc1(ByVal Folder As String)
Dim fso As New FileSystemObject
Dim objFile, objFolder
Set objFolder = fso.getFolder(Folder)
For Each objFile In objFolder.Files
MyProc2 objFile.Path
Next
For Each objFolder In objFolder.SubFolders
MyProc1 objFolder '递归遍历整颗树
Next
End Sub
Sub MyProc2(FileName As String)
Debug.Print FileName
End Sub
'引用Microsoft Scripting Runtime
Private Sub Command1_Click()
Dim pFolder As String, fso As New FileSystemObject
pFolder = "D:\12"
Dim objFile, objFolder
Set objFolder = fso.getFolder(pFolder)
For Each objFile In objFolder.Files
Debug.Print objFile.Path
Next
For Each objFolder In objFolder.SubFolders
Debug.Print objFolder
Next
End Sub