Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/318.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 程序执行+;C中表单的参数#_C#_.net_Windows - Fatal编程技术网

C# 程序执行+;C中表单的参数#

C# 程序执行+;C中表单的参数#,c#,.net,windows,C#,.net,Windows,我目前正试图执行一个带有C形式参数的程序。我的守则如下: private void button1_Click_1(object sender, EventArgs e) { Process.Start("nan.exe"); } 尽管我试图传递此参数:“nan.exe C:\Windows\System32” 在我的情况下,如何才能做到这一点?使用: Process.Start("nan.exe", @"c:\windows\system32");

我目前正试图执行一个带有C形式参数的程序。我的守则如下:

    private void button1_Click_1(object sender, EventArgs e)
    {
        Process.Start("nan.exe");

    }
尽管我试图传递此参数:“nan.exe C:\Windows\System32”

在我的情况下,如何才能做到这一点?

使用:

 Process.Start("nan.exe", @"c:\windows\system32");
建议使用Environment.GetFolderPath()。

使用:

 Process.Start("nan.exe", @"c:\windows\system32");
建议使用Environment.GetFolderPath()。

您可以使用对象来完成此操作:

// where fileName and arguments is what you need:
Process p = new Process();
p.StartInfo = new ProcessStartInfo(@"nan.exe", @"C:\windows\system32");
p.Start();
可以使用对象为您执行此操作:

// where fileName and arguments is what you need:
Process p = new Process();
p.StartInfo = new ProcessStartInfo(@"nan.exe", @"C:\windows\system32");
p.Start();

谢谢,但是否可以使用envorioment变量,如%TEMP%等?是的,传递任何您想要的内容。比如Environment.GetEnvironmentVariable(“TEMP”)@Mike:为此,您需要使用方法
System.Environment.GetEnvironmentVariable()
谢谢,但是可以使用Environment变量,例如%TEMP%等吗?是的,传递您想要的任何内容。比如Environment.GetEnvironmentVariable(“TEMP”)@为此,您需要使用方法
System.Environment.GetEnvironmentVariable()