0

如下图所示,这看起来像一个文件对话框和文件夹浏览器。此对话框只能选择文件夹(而不是文件)。这是自定义控件吗?如果是这样,那么请给我建议如何制作它。这是一个 Winforms 应用程序。

在此处输入图像描述

4

2 回答 2

1

它是基于原生 Vista IFileDialog 的 OpenFileDialog 版本。打开 FOS_PICKFOLDERS。该选项未在 .NET 中公开,它在早期版本的 Windows 中不可用。您可以从Windows API Code Pack的 CommonOpenFileDialog.IsFolderPicker 属性中获取它的包装器。

于 2011-12-25T14:06:06.303 回答
0

使用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();

FolderBrowserDialog 的用户界面与您在屏幕截图中显示的对话框不同。如果它需要看起来像那样,阅读这个答案怎么样?

您还应该考虑使用第三方Ookii.Dialogs包装类。

于 2011-12-25T14:00:04.107 回答