Enrico
Enrico

Reputation: 2037

Opening a file in an application that is already running in WinForms

I know there is a question with the following title: "Opening a file in an application that is already running"

This gives the answer to the question targeting WPF applications. I am working on a WinForms application where doubleclicking a specific file should start the program and open the file. Of course this is simple. Now when the application is already running I would like to open a file in the running application when it is doubleclicked.

To do this the application needs to be a singleton. I prefer the Mutex approach as described in this great article of "Sanity Free Coding"

Now I would like to know how to open a doubleclicked file into the running singleton WinForms applications. Any help would be appreciated.

Upvotes: 0

Views: 400

Answers (1)

Akku
Akku

Reputation: 4454

I think this project does what you want. Also, you should get the file opened as a parameter for your singleton instance. I have not tested it though, use another implementation but I don't need more parameters from the second instance.

Upvotes: 1

Related Questions