gunboxer
gunboxer

Reputation: 49

Arguments transmission to C# console application

I have simple C# console application:

static int Main(string[] args)
{
    Console.WriteLine("[" + args.Length + "]");
    for (int i = 0; i < args.Length; i++)
        Console.WriteLine(args[i]);
    Console.ReadKey();
}

Now I open windows console and type:

C: &&
cd "C:\Users\yagudin.rr\Documents\Visual Studio 2012\Projects\EmailSender\EmailSender\bin\Debug\" &&
"EmailSender.exe" "C:\Users\yagudin.rr\Documents\Visual Studio 2012\Projects\EmailSender\EmailSender\bin\Debug\" "C:\Program Files (x86)\FastReports\FastReport Studio\Bin\"

The output is following:

[4]
C:\Users\yagudin.rr\Documents\Visual Studio 2012\Projects\EmailSender\EmailSender\bin\Debug" C:\Program
Files
(x86)\FastReports\FastReport
Studio\Bin"

But I want to see this:

[2]
C:\Users\yagudin.rr\Documents\Visual Studio 2012\Projects\EmailSender\EmailSender\bin\Debug\
C:\Program Files (x86)\FastReports\FastReport Studio\Bin\

I seems to bee easy but I have already spent a lot of time to find solution. Thank you.

Upvotes: 0

Views: 135

Answers (1)

Daniel Hilgarth
Daniel Hilgarth

Reputation: 174289

You escape the ending quotes in your command line with the backslashes at the end of the pathes (after EmailSender and after Bin).
Remove them:

"EmailSender.exe" "C:\Users\yagudin.rr\Documents\Visual Studio 2012\Projects\EmailSender\EmailSender\bin\Debug" "C:\Program Files (x86)\FastReports\FastReport Studio\Bin"

If you wish to include the backslash, you will need to escape it, when it comes before a quote:

"EmailSender.exe" "C:\Users\yagudin.rr\Documents\Visual Studio 2012\Projects\EmailSender\EmailSender\bin\Debug\\" "C:\Program Files (x86)\FastReports\FastReport Studio\Bin\\"

Upvotes: 2

Related Questions