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.
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答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.
回答2:
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.