gpt4 book ai didi

c# - 使用参数启动程序

转载 作者:IT王子 更新时间:2023-10-29 04:37:06 25 4
gpt4 key购买 nike

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

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

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

最佳答案

您可以使用 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);

关于c# - 使用参数启动程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5168612/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com