command line arguments not recognized

G

gopal

static void Main(string[] args)
{
....
....
}


I have an EXE now. I am now giving one of the arguments

as
EXE C:\Documents and Settings\121308\Desktop\First.xml.

The problem is i am not able to parse the XML file. I am getting the
message at command line as

'C:\Documents' is not recognized as an internal or external command,
operable program or batch file.

How can read a file from a folder which has spaces in the folder name
itself like the one
mentioned above as Documents and settings.

Should user give the arguments with in Quotes/ or is there any other
smart way


Thanks
JP
 
D

Dave Shooter

Most applications expect the arguments in quotes, though you could
concatenate them back into a single string (including spaces).

static void Main(string[] args)
{
StringBuilder sb = new StringBuilder();
for (int i = 0; i < args.Length; i++)
{
sb.Append(args);
if (i < args.Length - 1)
{
sb.Append(" ");
}
}
Console.Out.WriteLine(sb.ToString());
}



gopal said:
static void Main(string[] args)
{
....
....
}


I have an EXE now. I am now giving one of the arguments

as
EXE C:\Documents and Settings\121308\Desktop\First.xml.

The problem is i am not able to parse the XML file. I am getting the
message at command line as

'C:\Documents' is not recognized as an internal or external command,
operable program or batch file.

How can read a file from a folder which has spaces in the folder name
itself like the one
mentioned above as Documents and settings.

Should user give the arguments with in Quotes/ or is there any other
smart way


Thanks
JP
 
C

Chan Ming Man

Yes user should do this:

"C:\Documents and Settings\121308\Desktop\First.xml"

chanmm

gopal said:
static void Main(string[] args)
{
....
....
}


I have an EXE now. I am now giving one of the arguments

as
EXE C:\Documents and Settings\121308\Desktop\First.xml.

The problem is i am not able to parse the XML file. I am getting the
message at command line as

'C:\Documents' is not recognized as an internal or external command,
operable program or batch file.

How can read a file from a folder which has spaces in the folder name
itself like the one
mentioned above as Documents and settings.

Should user give the arguments with in Quotes/ or is there any other
smart way


Thanks
JP
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top