如何使用多个参数运行应用程序?

时间:2014-05-08 12:08:44

标签: c# windows

public static void RunProcess(string FileName, string Arguments, ProcessWindowStyle WindowStyle, bool WaitforExit)
{
    MessageBox.Show("Runnig the process :- File name- " + FileName.ToString() + "argumetns- " + Arguments.ToString() + "windowStyle- " + WindowStyle.ToString() + "WaitForExit- " + WaitforExit.ToString());
    Process MyProcess = new Process();
    MyProcess.StartInfo.FileName = FileName;
    MyProcess.StartInfo.Arguments = Arguments;
    MyProcess.StartInfo.WindowStyle = WindowStyle;
    MyProcess.Start();
    if (WaitforExit)
        MyProcess.WaitForExit();
}

这里的论点也有一些空格。!!

1 个答案:

答案 0 :(得分:0)

如果你在谈论一般的参数中的空格,那么你需要用双qoutes包装参数:

MyProcess.StartInfo.Arguments = "\"this argument has spaces\"";

因此,请确保将传递给您的方法的参数发生。