问题
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