As you can see in the picture below, this looks like a file dialog and folder browser. This dialog can select only folder(not file). Is this a custom control? If so, then please give me advice on how to make it. This is a Winforms application.
Asked
Active
Viewed 344 times
0

bfavaretto
- 71,580
- 16
- 111
- 150

Sungguk Lim
- 6,109
- 7
- 43
- 63
-
can you please tell us if you are trying to do this with WPF or with Windows Forms? and did you mean "... but **not** files" instead of "but file"? – Adam Dec 25 '11 at 13:27
-
ok thankyou, this is winform application which can select only folder not file. – Sungguk Lim Dec 25 '11 at 13:55
2 Answers
1
It is the native Vista IFileDialog based version of OpenFileDialog. With the FOS_PICKFOLDERS turned on. That option is not exposed in .NET, it isn't available on earlier versions of Windows. You can get a wrapper for it from the Windows API Code Pack, CommonOpenFileDialog.IsFolderPicker property.

Hans Passant
- 922,412
- 146
- 1,693
- 2,536
-
Do earlier versions of Windows fall back to the old tree view folder browser? – BoltClock Dec 25 '11 at 14:08
-
@Bolt - there's no fallback in the code pack wrapper, it will simply fail trying to create the IFileDialog instance. It has to be done by your own code, Environment.OSVersion property. – Hans Passant Dec 25 '11 at 14:29
-
0
use the FolderBrowserDialog:
FolderBrowserDialog dialog = new FolderBrowserDialog();
dialog.Description = "Select a folder";
DialogResult result = dialog.ShowDialog();
String selectedFolder = String.Empty;
if (result == DialogResult.OK)
{
selectedFolder = dialog.SelectedPath;
}
dialog.Dispose();
The FolderBrowserDialog has a different user interface than the Dialog you showed in your screenshot. If it needs to look like that, how about reading this answer?
You should also consider using the third-party Ookii.Dialogs wrapper classes.