0

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.

Dennis Williamson
  • 346,391
  • 90
  • 374
  • 439
Semas
  • 869
  • 10
  • 22

2 Answers2

2

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
  • 30,270
  • 13
  • 89
  • 125
1

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
  • 2,165
  • 3
  • 25
  • 36