使用参数启动程序

mar*_*ark 20 c# command-line command-line-arguments

如何编写一个非常简单的程序,使用命令行导航到用户的Program Files目录中的程序,然后.exe使用参数启动?例如:

"C:\ etc\Program Files\ProgramFolder\Program.exe C:\ etc\desktop\file.spp C\etc\desktop\file.txt"

这将启动一个程序,其中包含某个项目文件和一个.txt文件.

Pao*_*lla 46

您可以使用ProcessStartInfo.Arguments属性指定程序的参数字符串:

ProcessStartInfo startInfo = new ProcessStartInfo();        
startInfo.FileName = @"C:\etc\Program Files\ProgramFolder\Program.exe";
startInfo.Arguments = @"C:\etc\desktop\file.spp C:\etc\desktop\file.txt";
Process.Start(startInfo);
Run Code Online (Sandbox Code Playgroud)