title: Split string containing command-line parameters into string[] in C#
body: <p>I have a single string that contains the command-line parameters to be passed to another executable and I need to extract the string[] containing the individual parameters in the same way that C# would if the commands had been specified on the command-line. The string[] will be used when executing another assemblies entry-point via reflection.</p>
  
  <p>Is there a standard function for this? Or is there a preferred method (regex?) for splitting the parameters correctly? It must handle '"' delimited strings that may contain spaces correctly, so I can't just split on ' '.</p>
  
  <p>Example string:</p>
  
  <pre><code>string parameterString = @"/src:""C:\tmp\Some Folder\Sub Folder"" /users:""abcdefg@hijkl.com"" tasks:""SomeTask,Some Other Task"" -someParam foo";
  </code></pre>
  
  <p>Example result:</p>
  
  <pre><code>string[] parameterArray = new string[] { 
    @"/src:C:\tmp\Some Folder\Sub Folder",
    @"/users:abcdefg@hijkl.com",
    @"tasks:SomeTask,Some Other Task",
    @"-someParam",
    @"foo"
  };
  </code></pre>
  
  <p>I do not need a command-line parsing library, just a way to get the String[] that should be generated.</p>
  
  <p><strong>Update</strong>: I had to change the expected result to match what is actually generated by C# (removed the extra "'s in the split strings)</p>