by Alexander Triantafyllou (5 Submissions)
Category: Files/File Controls/Input/Output
Compatability: Visual Basic 5.0
Difficulty: Beginner
Date Added: Wed 3rd February 2021
Rating: (3 Votes)
Recursive Get ALL files from a Folder and its Subfolders and its Subfolder Subfolders etc.
Assumes
First go to Project->References and include
"Microsoft Scripting Runtime"
Insert a Textbox called textbox1 with its multiline property set to true. Also a Command Button called Command1 .
public filetext as String
private sub command1_click()
Dim fso As New FileSystemObject
myfoldertext="C:\folder\"
call get_all_directory_files(fso.getfolder(myfoldertext))
text1.text=filetext
set fso=nothing
end sub
Public Sub get_all_directory_files(ByVal tfolder As folder)
Dim objfile As file
Dim objfolder As folder
Dim fso As New FileSystemObject
If tfolder <> "" Then
For Each objfile In tfolder.Files
'do the stuff we want with the files
filetext=filetext+objfile+ vbNewLine
Next
For Each objfolder In tfolder.SubFolders
Call get_all_directory_files(objfolder)
Next
Set fso = Nothing
End If
End Sub
No comments have been posted about Recursive Get ALL files from a Folder and its Subfolders and its Subfolder Subfolders etc.. Why not be the first to post a comment about Recursive Get ALL files from a Folder and its Subfolders and its Subfolder Subfolders etc..