Menu

#2 Incorrect constructor Parse

open
nobody
None
5
2007-10-08
2007-10-08
Anonymous
No

The constructor public void Parse(string[] args) does not take into account arguments containing spaces. A more correct solution is:

public void Parse(string[] args)
{
string commandLine = "";
foreach (string arg in args)
{
if (commandLine.Length > 0)
{
commandLine += " ";
}
if (!String.IsNullOrEmpty(arg) && arg.Contains(" "))
{
commandLine += "\"" + arg + "\"";
}
else
{
commandLine += arg;
}
}

Probably this leads to problems

Discussion


Log in to post a comment.