0

(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?

Joe Martiniello
  • 323
  • 1
  • 3
  • 13
  • 2
    Yes, your app just works on if starting with file parameters, and an instance already exists, make call to instance to say open it, and hide the second one that started – BugFinder Nov 10 '16 at 15:35
  • 4
    Try searching on `.net single instance application`. It takes some amount of work, it doesn't just happen with the flick of an option. – Damien_The_Unbeliever Nov 10 '16 at 15:35
  • @Damien_The_Unbeliever good, i try to follow this http://stackoverflow.com/questions/19147/what-is-the-correct-way-to-create-a-single-instance-application – Joe Martiniello Nov 10 '16 at 16:46

1 Answers1

2

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.

adv12
  • 8,443
  • 2
  • 24
  • 48