打开程序从C# - 还指定工作目录 [英] Open Program from C# - also specifying the working directory

查看:126
本文介绍了打开程序从C# - 还指定工作目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一些代码,启动一个外部程序,但是否可以指定工作目录,作为外部程序是一个控制台程序:



代码:

 私人无效button5_Click_2(对象发件人,EventArgs五)
{
System.Diagnostics.Process.Start( @update\update.exe);
}


解决方案

是的,这是可能的,使用 的ProcessStartInfo 对象指定您需要的所有PARAMS,然后只将它传递给这样的开始方法:

  ... 
使用System.Diagnostics程序;
...

变种PSI =新的ProcessStartInfo(@update\update.exe);
psi.WorkingDirectory = @C:\workingDirectory
的Process.Start(PSI);


I have some code that launches an external program, although is it possible to specify the working directory, as the external program is a console program:

Code:

private void button5_Click_2(object sender, EventArgs e)
    {
        System.Diagnostics.Process.Start(@"update\update.exe");
    }

解决方案

Yes, it's possible, use ProcessStartInfo object to specify all the params you need and then just pass it to the Start method like that:

...
using System.Diagnostics;
...

var psi = new ProcessStartInfo(@"update\update.exe");
  psi.WorkingDirectory = @"C:\workingDirectory";
Process.Start(psi);

这篇关于打开程序从C# - 还指定工作目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆