开发者

C# - Using switches when launching processes

I have code that launches a pr开发者_开发问答ogram:

Process.Start("cmd.exe", "/c test.exe \"\" > output.txt").WaitForExit();

Although instead I would like to use a parameter / switch with test.exe:

test.exe -F input.txt

How could this be done?


Use ProcessStartInfo.Arguments. There is an example in the msdn page.

    var process = new Process
                      {
                          StartInfo = new ProcessStartInfo
                                          {
                                              FileName = "test.exe",
                                              Arguments = "-F input.txt",
                                          }
                      };
    process.Start();
    process.WaitForExit();
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜