1

I am launching multiple files from a foreach with this code and it works fine unless the extension isn't associated with any software.

Process proc = new Process();
proc.StartInfo.FileName = filename;
proc.StartInfo.UseShellExecute = true;
proc.Start();

In this case Windows will display the "How do you want to open this file?" dialog for all the files but when I select a software for the first file, all the other dialogs disappear with the first one. So I am not able to open any other file.

There is any way to make C# waiting until the user select a software which I guess would be when the "How do you want to open this file" dialog will be closed?

robin
  • 66
  • 1
  • 3
  • Did you checked https://stackoverflow.com/questions/4726441/how-can-i-show-the-open-with-file-dialog already? – Fruchtzwerg Jun 19 '17 at 14:02
  • @Fruchtzwerg I don't think that's what the OP is asking for. It sounds to me like they want to know how to use the option selected in the "open with" dialog to open multiple unassociated files with the selected option. Currently, he can only open the first one. – Knowledge Cube Jun 19 '17 at 14:11

1 Answers1

2

The CodeProject example here https://www.codeproject.com/articles/43675/c-fileassociation-class shows how to read and write file associations in C#.

You can use this example to check that there is an existing file association between each Process.Start(). If there is no file association then only launch one file at a time; if the user creates a file association when nominating a program, then you can go ahead and load all the rest of the files.

PhillipH
  • 6,182
  • 1
  • 15
  • 25