Visual Basic List subdirectories in a directory

不想你离开。 提交于 2021-01-27 12:42:08

问题


How can I do this? I tried doing looking in

My.Computer.Filesystem

and

FileIO.Filesystem

回答1:


Try this:

System.IO.Directory.GetDirectories("Directory Path");

This will return a String() (string array) of the subdirectories.

Directory.GetDirectories Method

Note that there are 3 overloads for this method. The first one (shown above) simply takes the supplied directory and lists subdirectories.

GetDirectories(path, searchPattern) takes the path and a search pattern (like "my*" - which would list all directories that start with "my").

GetDirectories(path, searchPattern, searchOption) is like the second one, but searchOption indicates whether or not to search subdirectories within the current directory. Values are SearchOption.TopDirectoryOnly or SearchOption.AllDirectories.




回答2:


Use System.IO.DirectoryInfo or System.IO.Directory class methods.



来源:https://stackoverflow.com/questions/7212199/visual-basic-list-subdirectories-in-a-directory

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!