Is there a simple method for getting a directory listing (e.g., DirectoryPathCollection) for a given directory path?
I'd like to be able to get all directories easily for the current directory as well as from a given path.
I'm not seeing anything obvious in Directory Operations reference, nor in DirectoryPath or DirectoryAliases.
Workarounds
So far, I've found a couple approaches that do work.
Using the GlobbingAliases.GetDirectories
method with an argument to match all, but that seems like a bit of a hack. (It also has some quirks for trying to get sub-directories, but that is going to be a separate issue I'll investigate.)
var allDirectories = GetDirectories(@".\*");
Additionally, I have had luck just going directly to System.IO.Directory
methods.
var allDirectories = System.IO.Directory.GetDirectories(".", "*", System.IO.SearchOption.TopDirectoryOnly).Select (d => new DirectoryPath(d));