Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Open all files when user right clicks and selects "Open With"

Tags:

c#

wpf

I have an application written in WPF/C# that can take multiple files as command line arguments. When I run it from the command line with multiple files it opens all of them. When I select multiple files in an explorer window and drag them to the applications icon it opens all of them. But if I select multiple files in explorer and right click, select Open With, and then select my application it only opens the last one. Is there a way to tell Windows that my application can handle more than one file? I've noticed that some programs seem to work that way while others do not.

like image 463
juharr Avatar asked Nov 15 '22 09:11

juharr


1 Answers

The shell actually tries to start a separate instance of your application for each file selected. Your app will need to (a) ensure that only the first instance actually shows its UI, and (b) do some inter-process communication to pass the files from the later instances to the first instance. You might already be doing (a), but not (b), which would explain why you only see one file get opened. See the second question (the part about "Single-Instance Apps") on Stephen Toub's post about this. You also may want to read about Dynamic Data Exchange (DDE), which is a common way to pass information between instances of an application.

like image 183
JaredReisinger Avatar answered Dec 26 '22 02:12

JaredReisinger