Alexander Forbes-Reed
Alexander Forbes-Reed

Reputation: 2975

Opening a file in an application that is already running

I have it set so if you open a file, it launches my application and adds it to the start-up arguments. But how can I make it so if I double click on a file it loads it in the application that's already running? Rather than loading each file into it's own instance of the application.

Upvotes: 1

Views: 1866

Answers (3)

Shiridish
Shiridish

Reputation: 4962

Mutex is want you need to have a single instance of the application.

bool createdNew = true;
using (Mutex mutex = new Mutex(true, "MyApplicationName", out createdNew))
{
if (createdNew)
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new MainForm());
}
}

You can refer this LINK for detailed information.

Upvotes: 2

Ria
Ria

Reputation: 10357

You need to make your application single-Instance, see this article:

Upvotes: 0

vishal patel
vishal patel

Reputation: 71

use mdiParent and child forms in C# I think it's great feature of vs C#


for more inforamtion: http://msdn.microsoft.com/en-us/library/d4dabts7%28v=vs.80%29.aspx

Upvotes: 0

Related Questions