user449921
user449921

Reputation: 251

folderbrowserdialog selected path

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

Answers (5)

GvS
GvS

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

Harvey Kwok
Harvey Kwok

Reputation: 11873

DirectoryInfo dir = new DirectoryInfo(folderBrowserDialog1.SelectedPath);
foreach (DirectoryInfo subDir in dir.GetDirectories())
{
    Console.Out.WriteLine(subDir.Name);
}

Upvotes: 1

zsalzbank
zsalzbank

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

THE DOCTOR
THE DOCTOR

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

SLaks
SLaks

Reputation: 887453

You're looking for the Directory.GetDirectories method.

Upvotes: 0

Related Questions