0

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.

enter image description here

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 Answers2

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
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.

Community
  • 1
  • 1
Adam
  • 15,537
  • 2
  • 42
  • 63