从Windows窗体运行.exe应用程序

Ret*_*try 8 c# vb.net windows-forms-designer visual-c#-express-2010

我有一个应用程序,我在命令提示符下运行如下:

C:\ some_location>"myapplication.exe"headerfile.h

我想创建一个Windows表单应用程序,用户可以在其中指定可执行文件的位置以及头文件,以便Windows窗体可以为他执行此操作,用户不必转到命令行执行此操作.

我对C#很新,所以有人可以帮帮我吗?谢谢!

Jai*_*res 24

你需要使用这个Process类:

Process.Start(@"C:\some_location\myapplication.exe");
Run Code Online (Sandbox Code Playgroud)

对于论点:

ProcessStartInfo startInfo = new ProcessStartInfo();
startInfo.FileName = @"C:\some_location\myapplication.exe";
startInfo.Arguments = "header.h";
Process.Start(startInfo);
Run Code Online (Sandbox Code Playgroud)

显然你可以从文本框中提取这些名称/参数.


Agh*_*oub 6

您可以尝试使用以下代码:

ProcessStartInfo startInfo = new ProcessStartInfo("yourExecutable.exe");

startInfo.Arguments = "header.h"; // Your arguments

Process.Start(startInfo);
Run Code Online (Sandbox Code Playgroud)