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();
精彩评论