title: How do I find out if a process is already running using c#?
body: <p>I have C# winforms application that needs to start an external exe from time to time, but I do not wish to start another process if one is already running, but rather switch to it.</p>
  
  <p>So how in C# would I so this in the example below?</p>
  
  <pre><code>using System.Diagnostics;
  
  ...
  
  Process foo = new Process();
  
  foo.StartInfo.FileName = @"C:\bar\foo.exe";
  foo.StartInfo.Arguments = "Username Password";
  
  bool isRunning = //TODO: Check to see if process foo.exe is already running
  
  
  if (isRunning)
  {
     //TODO: Switch to foo.exe process
  }
  else
  {
     foo.Start(); 
  }
  </code></pre>