vb: how to search, list files in folder with subfolder?
Website Design
Website Promotion
Graphic Design
Programming
Free Software
Computer Tips
Discount Stores
|
This site provides users with the information about vb, visual basic, vb6, search files in directory, subdirectory, list files in directory, subdirectory, search files in folder, subfolder, list files in folder, subfolder, and more.
If you think that this site is helpful, please recommend your friends to visit our site.
How to search, list files in folder with subfolder?
The following is the code to search, list files in directory with subdirectory:
Please note that recursive function will be needed to go through the sub-directories.
Private Sub Command1_Click()
SearchFolder "C:\Test\"
End Sub
Private Sub SearchFolder(sFolderPath As String)
Dim fs As New FileSystemObject
Dim fsFile
Dim fsFolder As Folder
Dim sFolder As Folder
Set fsFolder = fs.GetFolder(sFolderPath)
For Each fsFile In fsFolder.Files
lstTest.AddItem fsFile
Next fsFile
For Each sFolder In fsFolder.sFolders
Call SearchFolder(sFolder.Path)
Next sFolder
Set fsFolder = Nothing
End Sub
|