c# - 如何为多个文件夹(或文件)选择器配置对话框?
问题描述
我正在使用这个库https://github.com/augustoproiete/ookii-dialogs-wpf进行对话演示。
我正在使用这样的对话框来选择单个文件夹
private void Btn_path_to_save_processed_clip_folder_Click(object sender, RoutedEventArgs e)
{
var dialog = new Ookii.Dialogs.Wpf.VistaFolderBrowserDialog
{
Description = "Select where to save processed clip folder",
SelectedPath = m_TbClipSaveDirectory,
UseDescriptionForTitle = true
};
if (dialog.ShowDialog(Application.Current.MainWindow).GetValueOrDefault())
{
m_TbClipSaveDirectory = dialog.SelectedPath;
}
}
问题是 - 是否可以一次选择几个文件夹?
或者也许其他一些方式?
解决方案
最终我用 NuGet 做到了
1)右键单击项目->管理NuGet包->在浏览选项卡中填充WindowsAPICodePack-Shell
并设置为所需的包
2) 创建对话框
using var dialog = new CommonOpenFileDialog
{
IsFolderPicker = true,
Multiselect = true
};
在这里您可以看到两个设置IsFolderPicker
- 为了只选择文件夹而不是文件和Multiselect
- 用于多选
最终结果
if (dialog.ShowDialog() == CommonFileDialogResult.Ok)
{
var folders = dialog.FileNames;
MessageBox.Show(string.Join("\n", folders));
}
结果是:
推荐阅读
- python - Python导入消息模块不起作用
- flutter - 每次更新数据时如何在颤振中重建完整视图
- javascript - 如何创建一个将新元素添加到空数组(JS)中的函数?
- r - 如何确保 3 个单独的 dfs 只包含相同的列?
- c# - 在 docker-compose 中访问 GRPC 服务
- git - `export GPG_TTY=$(tty)` 的签名问题
- javascript - 如何将 CSS 过渡(例如淡入)应用到 React 中的项目列表,以便它们的动画在渲染时一个接一个地排序?
- javascript - 来自给定位置的星图图像
- javascript - Javascript 将 BigInt 转换为日期时间和格式
- c# - 具有多个连接和包含的 LINQ 查询不起作用