4

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..?

4

2 回答 2

2

explorer.exe /select只需要 1 个参数。来自知识库 314853

/select,打开一个带有选定文件夹、文件或程序的窗口视图。

于 2010-04-12T07:31:38.770 回答
0

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

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

PS string.Join是 .NET 中一个未被充分利用的特性

于 2010-04-12T08:13:34.743 回答