Click here to Skip to main content
15,891,849 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I was wondering how to get a list of all files in a directory including in all of its folders and subfolders? How can I do this in vb.net???
Posted

1 solution

  Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

FolderBrowserDialog1.ShowDialog()
        GetDirectoryandFiles(FolderBrowserDialog1.SelectedPath)


End Sub
Private Sub GetDirectoryandFiles(ByVal strPath As String)
        Try
            Dim strDir() As String
            Dim strFile() As String
            strDir = System.IO.Directory.GetDirectories(strPath)
            strFile = System.IO.Directory.GetFiles(FolderBrowserDialog1.SelectedPath)
            For i As Integer = 0 To strFile.Length - 1
                ListBox1.Items.Add(strFile(i))
            Next
            For i As Integer = 0 To strDir.Length - 1
                ListBox1.Items.Add(strDir(i))
                GetDirectoryandFiles(strDir(i))
            Next

        Catch ex As Exception
        End Try
  End Sub
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900