Joe Martiniello
Joe Martiniello

Reputation: 323

c# open file association at runtime

(Sorry for my bad english)

Hi I have a problem.

I need to open the associated files already in my program while it is running.

If we take example visual studio, when I opened the ide and I double-click on a file example test.cs

Do not opening a new application, But he added a tab with the new file.

And 'possible to do such a thing?

Upvotes: 0

Views: 203

Answers (1)

adv12
adv12

Reputation: 8551

As you've observed, Windows Explorer will try to launch a new instance of your app when you double-click a file associated with your application. You can't change that. What you can do is have the new instance check whether an instance is already running and, if so, tell the running instance to load the file. There are lots of ways to establish this sort of communication. You could listen on a port, periodically check for a file in a particular location, etc. How to do it is up to you.

Upvotes: 2

Related Questions