我有这样的代码来启动命令行应用程序的正确语法:什么是传递多个参数
private void LaunchCommandLineApp(string latestStudents, string latestTopics)
{
// Use ProcessStartInfo class
ProcessStartInfo startInfo = new ProcessStartInfo();
startInfo.CreateNoWindow = false;
startInfo.UseShellExecute = false;
startInfo.FileName = "ConsoleApplication2.exe";
startInfo.WindowStyle = ProcessWindowStyle.Hidden;
startInfo.Arguments =
try
{
// Start the process with the info we specified.
// Call WaitForExit and then the using statement will close.
using (Process exeProcess = Process.Start(startInfo))
{
exeProcess.WaitForExit();
}
}
catch
{
// Log error.
}
}
什么是合格latestStudents & latestTopics在作为参数行startInfo.Arguments =
正确的语法?我尝试了所有我能想到的和一些但我仍然不明白的东西!
尝试就像命令提示符一样:startInfo.Arguments =“latestStudents latestTopics”; –
用空格分隔你的论点。这是一个链接,实际上是第一个,谷歌搜索后 https://msdn.microsoft.com/en-us/library/system.diagnostics.processstartinfo.arguments(v=vs.110).aspx –
你有没有_ConsoleApplication2.exe_的代码?如果是,那么看看应用程序如何期望传递的参数是微不足道的。如果不是的话,那么你至少应该有解释如何在命令行上放置参数的文档(如果有任何方法可以编程的话)。没有这些信息,没有失败的尝试,任何答案都是一种猜测。 – Steve