Open folder and select multiple files

In C #, I want to open explorer, and some files should be selected in this browser window. I do it like this:

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 arg file is selected. How to make all arg files be selected when explorer window opens ..? I think this is possible because I have seen many Windows applications that have this trick. In the example, when I import photos from my DSLR camera to the computer, finally, the Explorer window appears and all new imported images are selected.

Maybe there is some option so that all files are selected from the specified folder ..?

+4
source share
2 answers

explorer.exe /select accepts only one argument. From KB 314853 :

/ select, opens a window with the selected folder, file or program.

+2
source

Can you run each file in a loop?

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

PS string.Join is a very underused .NET function

0
source

Source: https://habr.com/ru/post/1306657/


All Articles