如何使用vb.net获取指定路径中所有目录和子目录的列表 [英] How to get the list of all directories and subdirectories in a specified path using vb.net
问题描述
我的目录结构如下.
父目录
---子目录1---子目录2------子目录2a------子目录2b---子目录3
Parent directory
---Sub directory 1
---Sub directory 2
------Sub directory2a
------Sub directory2b
---Sub directory 3
我在 VB.net 中编写以获取所有目录名称(包括所有级别的子目录)
I am writing in VB.net to fetch all the directory names (including sub directories in all the levels)
但是,在使用 directory.getfilesystementries(path) 时,我只获取顶级子目录.知道如何获取所有子级别的所有子目录名称吗?
However while using directory.getfilesystementries(path) I am getting only the top level sub directories. Any idea on how to fetch all the subdirectory names of all sub levels?
推荐答案
就这样使用:
Dim result = System.IO.Directory.EnumerateDirectories(path, "*", System.IO.SearchOption.AllDirectories)
诀窍是 SearchOption.AllDirectories
顺便说一句:你可以用你的 GetFileSystemEntries-Method 做同样的事情
BTW: you can do the same with your GetFileSystemEntries-Method
这篇关于如何使用vb.net获取指定路径中所有目录和子目录的列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!