打开文件夹并选择多个文件

发布于 2024-08-28 21:38:50 字数 661 浏览 3 评论 0原文

在 C# 中,我想打开资源管理器,并且必须在此资源管理器窗口中选择一些文件。我这样做:

        string fPath = newShabonFilePath;

        string arg = @"/select, ";

        int cnt = filePathes.Count;
        foreach (string s in filePathes)
        {
            if(cnt == 1)
                arg = arg + s;
            else
            {
                arg = arg + s + ",";
            }
            cnt--;
        }

        System.Diagnostics.Process.Start("explorer.exe", arg);

但只选择了“arg”的最后一个文件。当打开资源管理器窗口时,如何使 arg 的所有文件都被选中?我认为这是可能的,因为我见过很多Windows应用程序,它们都有这个技巧。例如,当我将数码单反相机中的图片导入到电脑时,最终会出现 Windows 资源管理器,并且所有新导入的图像都会被选中。

也许有一些选项可以使所有文件从指定文件夹中选择..?

In C# I want to open explorer and in this explorer window must be selected some files. I do this like that:

        string fPath = newShabonFilePath;

        string arg = @"/select, ";

        int cnt = filePathes.Count;
        foreach (string s in filePathes)
        {
            if(cnt == 1)
                arg = arg + s;
            else
            {
                arg = arg + s + ",";
            }
            cnt--;
        }

        System.Diagnostics.Process.Start("explorer.exe", arg);

But only the last file of "arg" is selected. How to make that all files of arg would be selected, when explorer window is opened..? I think its possible to do that, becouse I have seen many Windows app programs, which have this trick. In example, when I import pictures from my DSLR camera to the pc, finally apears windows explorer and all the new imported images are selected.

Maybe there is some option, to make all files to be selected from specified folder..?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

甜妞爱困 2024-09-04 21:38:50

explorer.exe /select 仅采用 1 个参数。来自 知识库 314853

/select,打开窗口视图,并选择指定的文件夹、文件或程序。

explorer.exe /select only takes 1 argument. From KB 314853:

/select, Opens a window view with the specified folder, file, or program selected.

邮友 2024-09-04 21:38:50

你能在循环中启动每个文件吗?

foreach (string s in filePaths)
    System.Diagnostics.Process.Start("explorer.exe", "/select, "+s);

PS string.Join 是 .NET 的一个未被充分利用的功能

Could you launch each file in the loop?

foreach (string s in filePaths)
    System.Diagnostics.Process.Start("explorer.exe", "/select, "+s);

P.S. string.Join is a greatly underused feature of .NET

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文