【问题标题】:ProcessStartInfo.Arguments accept multiple arguments with double quotesProcessStartInfo.Arguments 接受带有双引号的多个参数
【发布时间】:2020-03-11 06:29:29
【问题描述】:
string CandlePath = "C:\\Program Files (x86)\\WiX Toolset v3.11\\bin\\candle.exe";
string BundlePath = "C:\\Solution Directory\\Bundle.wxs";
string wixObjPathToSave = "C:\\Solution Directory\\Bundle.wxs";
ProcessStartInfo processStartInfo = new ProcessStartInfo("cmd.exe"); 
processStartInfo.WindowStyle = ProcessWindowStyle.Normal;
processStartInfo.Arguments ="/k \"" + candlePath + "\" " +BundlePath + " " +wixObjPathToSave;

当我像上面一样传递参数时,进程正在接受参数,但 candle.exe 给出错误“C:\Solution”不被识别为内部或外部命令,这是预期的,因为我没有为 bundlePath 和 wixobjPathToSave 提供双引号

processStartInfo.Arguments ="/k \"" + candlePath + "\" \"" +BundlePath + "\" \"" + wixObjPathToSave +"\"";

当我像上面一样传递参数时,该过程会给出错误,即“C:\Program”不被识别为内部或外部命令。

我做错了什么?

【问题讨论】:

  • 在上面的代码中sn -p string wixobjPathToSave="C:\\Solution Directory\\Bundle.wixobj";

标签: c# process.start wix3.11


【解决方案1】:

我得到了答案

processStartInfo.Arguments ="/k \"\"" + candlePath + "\" \"" +BundlePath + "\" \"" + wixObjPathToSave +"\"";

我在前面多加了一个双引号。现在它工作正常。但我只有一个疑问,为什么需要额外的双引号?

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-12-22
    • 1970-01-01
    • 1970-01-01
    • 2012-10-13
    • 2021-07-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多