by Dero (2 Submissions)
Category: Files/File Controls/Input/Output
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Sun 7th March 2004
Date Added: Mon 8th February 2021
Rating: (1 Votes)
Search folders (recursively or not) for files of a particular extension
API Declarations
' for the original code which i have heavily edited.
' Use: for instance, if you wanted to find all the
' mp3s in your root music directory, you would call -
'Call get_files(fso.GetFolder("C:\music"), ".mp3", True)
'So: ^ ^ ^
' Directory extension recursive or not
'Email me if you have any questions!
Dim filetext As String
Dim objfile As File
Dim objfolder As Folder
Dim fso As New FileSystemObject
Dim j As Integer
j = 0
If tfolder <> "" Then
For Each objfile In tfolder.Files
filetext = filetext + objfile
If Right(filetext, 4) = extn Then
List1.AddItem filetext, j
Label10.Caption = Label10.Caption + filetext + vbNewLine
j = j + 1
End If
filetext = ""
Next
If recurse = True Then
For Each objfolder In tfolder.SubFolders
Call get_files(objfolder, extn, True)
Next
End If
Set fso = Nothing
End If
End Sub
No comments have been posted about Search folders (recursively or not) for files of a particular extension. Why not be the first to post a comment about Search folders (recursively or not) for files of a particular extension.