How to get the list of all directories and subdirectories in a specified path using vb.net

后端 未结 4 613
耶瑟儿~
耶瑟儿~ 2021-01-28 10:27

My directory structure is like below.

Parent directory
---Sub directory 1 ---Sub directory 2 ------Sub directory2a ------Sub directory2b ---Sub directory 3

4条回答
  •  南笙
    南笙 (楼主)
    2021-01-28 10:57

    The Directoryinfo object can provide all sorts of information and about a directory, including directories / Files even system files

    Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
        Dim dir As New DirectoryInfo("C:\")
        For Each dirItem As DirectoryInfo In dir.GetDirectories
            MsgBox(dirItem.Name)
        Next
    End Sub
    

提交回复
热议问题