Find all directories in directory and return only name

后端 未结 5 1037
无人及你
无人及你 2020-12-21 11:37

I want to find all directories in one directory in vb.net.

I found one script:

For Each Dir As String In Directory.GetDirectories(FolderName)
    Com         


        
5条回答
  •  轮回少年
    2020-12-21 12:12

    Give this a try

        For Each d As String In IO.Directory.GetDirectories(FolderName)
            'IO.Path.GetFileName
            'The characters after the last directory character in path.
            ComboBox3.Items.Add(IO.Path.GetFileName(d))
        Next
    

    This takes advantage of the fact that you have a list of directories and what IO.Path.GetFileName actually does.

提交回复
热议问题