0

Hi,

In vb.net, how would you search a folder and get it to make a list of the files in the directory and what sub-folders the files are in are in? Then, put the results in a multiline textbox.

The list would look something like if we were searching in C:\foo:

C:\foo\bar.txt
C:\foo\carrots\potatoes.exe
...

Thanks,

James

Edited by jamesl22: n/a

3
Contributors
3
Replies
5
Views
6 Years
Discussion Span
Last Post by Unhnd_Exception
0

basically you want to print the directory structure. I dont know the vb.net syntax much but u can try this:

search for all files inside a folder (using recursion) and then try to get the parent path of the file. Then you can save that path in a multiline textbox

0

basically you want to print the directory structure. I dont know the vb.net syntax much but u can try this:

search for all files inside a folder (using recursion) and then try to get the parent path of the file. Then you can save that path in a multiline textbox

Can anybody tell me how to do this is vb?

0
Private Sub btnGetFiles_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnGetFiles.Click  

    PrintDirectory("C:\TestD")

End Sub

Private Sub PrintDirectory(ByVal DirectoryPath As String)

    For Each FileName As String In System.IO.Directory.GetFiles(DirectoryPath)
        txtDirectoryInfo.Text &= FileName & vbCrLf
    Next

    For Each Directory As String In System.IO.Directory.GetDirectories(DirectoryPath)
        PrintDirectory(Directory)
    Next

End Sub
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.