我有简单的C#控制台应用程序:
static int Main(string[] args)
{
Console.WriteLine("[" + args.Length + "]");
for (int i = 0; i < args.Length; i++)
Console.WriteLine(args[i]);
Console.ReadKey();
}
现在我打开Windows控制台并输入:
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\"
输出如下:
[4]
C:\Users\yagudin.rr\Documents\Visual Studio 2012\Projects\EmailSender\EmailSender\bin\Debug" C:\Program
Files
(x86)\FastReports\FastReport
Studio\Bin"
但我想看到这个:
[2]
C:\Users\yagudin.rr\Documents\Visual Studio 2012\Projects\EmailSender\EmailSender\bin\Debug\
C:\Program Files (x86)\FastReports\FastReport Studio\Bin\
我似乎很容易,但我已经花了很多时间来寻找解决方案。谢谢。
答案 0 :(得分:2)
您可以使用修补程序末尾的反斜杠(EmailSender
之后和Bin
之后)在命令行中转义结尾引号。
删除它们:
"EmailSender.exe" "C:\Users\yagudin.rr\Documents\Visual Studio 2012\Projects\EmailSender\EmailSender\bin\Debug" "C:\Program Files (x86)\FastReports\FastReport Studio\Bin"
如果您希望包含反斜杠,则需要在报价出现之前将其转义:
"EmailSender.exe" "C:\Users\yagudin.rr\Documents\Visual Studio 2012\Projects\EmailSender\EmailSender\bin\Debug\\" "C:\Program Files (x86)\FastReports\FastReport Studio\Bin\\"