Reputation: 251
i'm using 'folderBrowserDialog1.SelectedPath' to have a path to chosen folder. How can i see the names of another folders in folder which is selected?
Upvotes: 0
Views: 4895
Reputation: 52518
The System.IO namespace contains a lot of tools for this. The Directory.GetDirectories
you can use to get al subfolders.
For example:
var folder = folderBrowserDialog1.SelectedPath;
var subFolders = System.IO.Directory.GetDirectories(folder);
Upvotes: 0
Reputation: 11873
DirectoryInfo dir = new DirectoryInfo(folderBrowserDialog1.SelectedPath);
foreach (DirectoryInfo subDir in dir.GetDirectories())
{
Console.Out.WriteLine(subDir.Name);
}
Upvotes: 1
Reputation: 9857
You probably want to use the DirectoryInfo.GetDirectories
method. See here: http://msdn.microsoft.com/en-us/library/system.io.directoryinfo.getdirectories(v=vs.71).aspx
Upvotes: 0
Reputation: 4555
The FolderBrowserDialog component is displayed at run time using the ShowDialog method. Set the RootFolder property to determine the top-most folder and any subfolders that will appear within the tree view of the dialog box. Once the dialog box has been shown, you can use the SelectedPath property to get the path of the folder that was selected
Upvotes: 0