tags:

views:

29

answers:

2

Hello. I'm making a program through which I will be able to send files to an FTP server just by right clicking "SendTo". The problem is that every time I click "SendTo" it opens a new exe file and it works as a separate program. I need to make it somehow to send the file with the already open program.

Thank you.

+1  A: 

Here is an example application with source code: Single Instance Application, Passing Command Line Arguments.

The examples uses .Net Remoting to pass the arguments between instances but you can change it to use WCF, sockets or pipes.

Giorgi
+1 This is what I use for a WPF application.
juharr
A: 

You can achieve a single instance with a Mutex.

Place this in your startup class. E.g. Program.cs

private static Mutex _mutex;

[STAThread]
static void Main (string[] args)
{
      // Ensure only one instance runs at a time
      _mutex = new Mutex (true, "MyMutexName");
      if (!_mutex.WaitOne (0, false))
      {
            return;
      }
}

But check MSDN for details: http://msdn.microsoft.com/en-us/library/ms686927%28VS.85%29.aspx

Jacques Bosch