0

我有简单的 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\

我似乎很容易,但我已经花了很多时间来寻找解决方案。谢谢你。

4

1 回答 1

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\\"
于 2013-09-09T07:43:57.660 回答