Mythodikal
New member
- Joined
- Sep 25, 2023
- Messages
- 1
- Programming Experience
- 1-3
Is there an easier way to do this than this way? I have tried using a backgroundworker and simple recursion, but I am trying to load my listbox with file locations from my main drive.
Sub scanSubfolders(ByVal FolderLocation As String)
Try
Dim di As New IO.DirectoryInfo(FolderLocation)
Dim aryFiles() As IO.FileInfo = di.GetFiles("*.*")
Dim aryDirs() As IO.DirectoryInfo = di.GetDirectories()
For Each fi As IO.FileInfo In aryFiles
Me.ListBox3.Items.Add(fi.FullName)
Next
For Each d As IO.DirectoryInfo In aryDirs
scanSubfolders(d.FullName)
Next
Catch ex As Exception
'Stop 'the catch should be more specific
End Try
End Sub
Sub scanSubfolders(ByVal FolderLocation As String)
Try
Dim di As New IO.DirectoryInfo(FolderLocation)
Dim aryFiles() As IO.FileInfo = di.GetFiles("*.*")
Dim aryDirs() As IO.DirectoryInfo = di.GetDirectories()
For Each fi As IO.FileInfo In aryFiles
Me.ListBox3.Items.Add(fi.FullName)
Next
For Each d As IO.DirectoryInfo In aryDirs
scanSubfolders(d.FullName)
Next
Catch ex As Exception
'Stop 'the catch should be more specific
End Try
End Sub