Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to open associated files in the same instance of an application

Tags:

c#

.net

I want to open files, which are doubleclicked in Explorer, in the same instance of my .Net application, e.g. in a new tab. How can I do this?

For now each file starts new instance of my application. Many programs can open files in the same instance, for example, Opera and Notepad++, so there is an easy way for sure.

like image 870
Alexei Avatar asked Apr 22 '10 10:04

Alexei


People also ask

How do I open a file with another program?

To open a file with an application other than the default, right-click the file and select the application you want from the top of the menu. If you do not see the application you want, select Open With Other Application. By default, the file manager only shows applications that are known to handle the file.


3 Answers

You may take a look at this post which illustrates a technique that could be used to have a single instance WinForms application.

like image 198
Darin Dimitrov Avatar answered Oct 01 '22 06:10

Darin Dimitrov


Might be an easier way to do it but the way I've done it is that if an instance is started with a filename as a parameter then it checks if there are any other instances and if so passes on the filename to that instance and the close itself down.

like image 41
Hans Olsson Avatar answered Oct 01 '22 06:10

Hans Olsson


In case you want to do the same, but in WPF rather than WinForms, the howto is explained here: What is the correct way to create a single-instance application?

like image 33
Benlitz Avatar answered Oct 01 '22 05:10

Benlitz