n00b1337
Sorry, I was rushing out the door and did not give you a complete view of things. Cut and paste this entire code excert into an empty form. Put a CommandButton and a ListBox on the form, then run the code.
Of course add the FileSystemObject reference to your code (Microsofts Scripting Runtime)
VB Code:
Option Explicit Dim FSys As FileSystemObject Sub ScanFolder(FolderSpec) Dim thisFolder As Folder Dim allFolders As Folders Dim thisFile As File Dim allFiles As Files Dim i As Integer Set thisFolder = FSys.GetFolder(FolderSpec) Set allFolders = thisFolder.SubFolders For Each thisFolder In allFolders List1.AddItem thisFolder.Path ' Add folder path to the listbox Set allFiles = thisFolder.Files If allFiles.Count > 0 Then For Each thisFile In allFiles List1.AddItem thisFolder.Path & "\" & thisFile.Name ' Add folder path and filename to listbox Next End If Set allFiles = Nothing ScanFolder thisFolder.Path DoEvents Next Set thisFolder = Nothing Set allFolders = Nothing End Sub Private Sub Command1_Click() ScanFolder ("c:\") MsgBox "ScanFolders Complete" End Sub Private Sub Form_Load() Set FSys = New FileSystemObject End Sub




Reply With Quote