For VB6.0 I would make use of the FileSystemObject
and a small recursive function.
Sub test()
Dim fso As New Scripting.FileSystemObject
Dim files As New Collection
Dim file As Scripting.file
GetFilesRecursive fso.GetFolder("C:YourFolder"), "zip", files, fso
For Each file In files
Debug.Print file.Name
Next file
End Sub
Sub GetFilesRecursive(f As Scripting.Folder, filter As String, c As Collection, fso As Scripting.FileSystemObject)
Dim sf As Scripting.Folder
Dim file As Scripting.file
For Each file In f.Files
If InStr(1, fso.GetExtensionName(file.Name), filter, vbTextCompare) = 1 Then
c.Add file, file.path
End If
Next file
For Each sf In f.SubFolders
GetFilesRecursive sf, filter, c, fso
Next sf
End Sub
This will not be lightning fast, though. Maximum performance can only be gained by directly using Win32 API functions like FindFirstFile and FindNextFile.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…