command line arguments given to a C# program are parsed wrong
<p>I wrote a little program, that has the following command line for example:</p>

<pre><code>prog.exe -p -z "E:\temp.zip" -v "f:\" -r -o -s –c
prog.exe -p -z "E:\temp.zip" -v f:\ -r -o -s –c
prog.exe -p -z "E:\temp.zip" -v "f:\log" -r -o -s –c
</code></pre>

<p>This command line is being generated by another program that inserts the quotation marks around the file and path names automatically to prevent spaces being recognized as argument separators.</p>

<p>The first command line is then being parsed by the .Net framework as:</p>

<pre><code>args     {string[5]}        string[]
[0]        "-p"      string
[1]        "-z"      string
[2]        "f:\\temp.zip"   string
[3]        "-v"      string
[4]        "f:\" -r -o -s -c" string
</code></pre>

<p>But it should be ( the result from the second command line): </p>

<pre><code>args      {string[9]}          string[]
[0]        "-p"                string
[1]        "-z"                string
[2]        "f:\\temp.zip"      string
[3]        "-v"                string
[4]        "f:\\"              string
[5]        "-r"                string
[6]        "-o"                string
[7]        "-s"                string
[8]        "-c"                string
</code></pre>

<p>A possible solution would be to check the file and path names in the calling application if they contain spaces and only then append the quotation marks around the names.</p>

<p>But is there another solution?</p>