title: Passing arguments to a console application
body: <p>I am able to successfully pass arguments into a console application using the following:</p>
  
  <pre><code>ProcessStartInfo psi = new ProcessStartInfo();
  psi.FileName = Properties.Settings.Default.EmailBlasterAppPath;
  
  string subject = txtSubject.Text.Replace(@"""", @"""""");
  string emailbody = txtEmail.Text.Replace(@"""", @"""""");
  string args = String.Format("{0},{1},{2},{3},{4}",
                              "SendPlainEmail",
                              B2BSession.Doctor.DoctorId.ToString(),
                              DocEmail.Trim(), subject, emailbody);
  
  psi.Arguments = args;
  psi.UseShellExecute = false;
  psi.CreateNoWindow = true;
  
  Process process = Process.Start(psi);
  </code></pre>
  
  <p>However, once inside the console application, the console app only expects parameters as single strings separated by a space (see below):</p>
  
  <pre><code>static void Main(string[] args)
  </code></pre>
  
  <p>My problem is that I'm passing a subject line and email body into the console application, but it only picks up the first word in the parameter. So, if I pass in something like this (note that "test subject line" should be one argument and "test body line" would be another argument) for a total of 5 arguments:</p>
  
  <p>SendPlainEmail 25498 test@test.com test subject line test body line </p>
  
  <p>but, the console app would parse it as having 9 arguments (one for each word):</p>
  
  <p>SendPlainEmail 25498 test@test.com test subject line test body line</p>
  
  <p>Is there a way to pass the parms into the console app with just the 5 arguments where the subject and body are treated as a single argument?</p>
  
  <p>So, as you can see, right before the Process.Start statement, what is contained in the psi.arguments property.</p>
  
  <p>The data is being passed correctly, it's just that the receiving console application can only receive an array of strings separated by a space. So, instead of the 4th and 5th arguments being "test subject line" and "test body line" respectively, the console app process it as the following:</p>
  
  <p>args[3] = test</p>
  
  <p>args[4] = subject</p>
  
  <p>args[5] = line</p>
  
  <p>args[6] = test</p>
  
  <p>args[7] = body</p>
  
  <p>args[8] = line</p>
  
  <p>So, in lieu of this, how can I treat "test subject line" and "test body line" as one item in the array respectively?</p>