我有一个控制台应用程序,它作为后台进程运行,并且有一个需要调用的exe。这个exe将完整的填充路径作为参数,然后加密该文件。 我这样做了:
Process.Start( "myapp.exe" );
但我想要的是:
Process.Start( "myapp.exe file1.txt" ); // File1 is parameter of that exe
但这不起作用。 寻求帮助&建议。
谢谢:)
答案 0 :(得分:2)
您想使用ProcessStartInfo
类。
有关如何使用此功能的示例,请参阅http://msdn.microsoft.com/en-us/library/system.diagnostics.process.startinfo.aspx和http://msdn.microsoft.com/en-us/library/system.diagnostics.processstartinfo.aspx。
使用Arguments
属性设置参数。
答案 1 :(得分:2)
使用类似的东西:
流程p =新流程();
p.StartInfo.UseShellExecute = false;
p.StartInfo.FileName =“myApp.exe”;
p.StartInfo.Arguments =“file1.txt”;
p.Start();
答案 2 :(得分:1)
尝试Process.Start("myapp.exe", "file1.txt");
答案 3 :(得分:1)
Process.Start("[drive]:\[directory]\myapp.exe", "file1.txt");
替换指示的实际驱动器和目录
答案 4 :(得分:0)
的Process.Start(小于the nameof the process
>,< the parameters
&GT)
在你的情况下
Process.Start("myapp.exe","file1.txt")