Reputation: 127
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.
Upvotes: 9
Views: 2485
Reputation: 43
Example using TCP-sockets: http://pieterjan.pro/?a=Projecten_csharp_DrawIt.php
Works for multiple files at once as well, and even for multiple files at the first time (when application not started yet)
The most important code blocks are:
The source code is available on the button "Broncode"
Upvotes: 0
Reputation: 2002
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?
Upvotes: 2
Reputation: 1038800
You may take a look at this post which illustrates a technique that could be used to have a single instance WinForms application.
Upvotes: 4
Reputation: 55009
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.
Upvotes: 1