多选文件夹和文件 [英] multi select folders and files

查看:41
本文介绍了多选文件夹和文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可以使用 OpenFileDialog 选择多个文件.(设置多选为真)

问题是如何同时选择多个文件和文件夹?

我知道 FolderBrowseDialog 是什么,我知道我应该按住 ctrl 或 shift!:D

假设一个文件夹包含5个文件夹和2个文件,场景是选择例如1个文件和2个文件夹.

我不知道为什么人们不赞成这个问题!!

----------------- 编辑 --------------------

假设有一个 OpenFileDialog,你可以在一个文件夹中选择任意数量的文件,好吗?我想要这样的东西,但也可以选择文件夹!因此 OpenFileDialog 返回 FileNames 数组中选定的文件名,该对话框返回类似 SelectedPaths 数组的内容,其中包含文件名和文件夹路径.

解决方案

Common Item Dialog(取代了 Open File Name Common Dialog Box)有几个自定义点.我还没有尝试过,但是通过挂钩 IFileDialogEvents 您应该能够根据需要改变行为.(您可能需要添加一些技巧,在 XP 样式文件对话框中使用 OFNHookProc 是可能的)

<小时>

尽管这意味着阅读大量令人沮丧的 Microsoft 文档,但它比开发自定义对话框更可取:

复制平台功能时,您必须复制所有功能.

这意味着例如通过 Ctrl+V、Shift+Ins 或上下文菜单粘贴文件,如果我刚写的那个 shell 扩展不起作用,我很生气.

it is possible to select multiple files using OpenFileDialog. (setting multiselect as true)

the question is how to select multiple files and folders at the same time?

I know what is FolderBrowseDialog, I know I should Hold ctrl or shift! :D

assume a folder contain 5 folder and 2 files, the scenario is to select for example 1 of files and 2 folders.

I don't know why people down vote this question!!

----------------- Edit --------------------

assume an OpenFileDialog, you can select as many file as you want in a folder, ok? I want something like this but with the ability to select folders too! so as OpenFileDialog return selected file names in FileNames array that dialog return something Like SelectedPaths array that contains filenames and folderpaths.

解决方案

The Common Item Dialog (which replaces the Open File Name Common Dialog Box) has a few points of customization. I haven't tried, but by hooking IFileDialogEvents you should be able to change behavior as you need. (You might need to add some trickery, it was possible with an OFNHookProc in XP style file dialog)


Even though this means reading a lot of frustrating Microsoft documentation, It's preferrable over developing a custom dialog:

When copying a platform feature, you have to copy all of it.

That means e.g. pasting files through Ctrl+V, Shift+Ins or the context menu, and if that shell extension I just wrote doesn't work, I'm pissed.

这篇关于多选文件夹和文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆