其中的arguments 参数, 是有个空格的问题的, 在外部程序接收参数的 (Winform) 是用过Main(string[] args) 。 其中args是数组 , 在StartInfo.Arguments中的参数的间隔是根据空格进行分断的。 所以如果在传递的参数中是空格的,就需要 在 参数前后追加 “"” 即:
string argument1 = """ + argv1 + """;
string argument2 = """ + argv2 + """;
Process process = new Process();
process.StartInfo.FileName = System.Environment.CurrentDirectory + "//test.exe";
process.StartInfo.Arguments = argument1 + " " + argument2;
process.StartInfo.UseShellExecute = true; ;
//启动
process.Start();
ok, 这样就能解决Process 传递参数的有空格的问题了。
以上所述是小编给大家介绍的C# 使用Process调用外部程序中所遇到的参数问题,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对ASPKU网站的支持!
注:相关教程知识阅读请移步到c#教程频道。










