title: How to escape path containing spaces
body: <p>To pass a path with spaces to .NET console application you should escape it. Probably not escape but surround with double quotes:</p>
  
  <pre><code>myapp.exe --path C:\Program Files\MyApp`
  </code></pre>
  
  <p>becomes</p>
  
  <pre><code>new string[] { "--path", "C:\Program", "Files\MyApp" }
  </code></pre>
  
  <p>but</p>
  
  <pre><code>myapp.exe --path "C:\Program Files\MyApp"
  </code></pre>
  
  <p>becomes</p>
  
  <pre><code>new string[] { "--path", "C:\Program Files\MyApp" }
  </code></pre>
  
  <p>and it works fine and you can parse that easily.</p>
  
  <p>I want to extend the set of parameters given with an addition one and start a new process with the resulting set of parameters:</p>
  
  <pre><code>new ProcessStartInfo(
      Assembly.GetEntryAssembly().Location,
      String.Join(" ", Enumerable.Concat(args, new[] { "--flag" })))
  </code></pre>
  
  <p>This becomes <code>myapp.exe --path C:\Program Files\MyApp --flag</code> where path drops its escaping.</p>
  
  <p>How to workaround it with common solution? (without searching each parameter's value requiring escaping and quoting it manually)</p>