如何启动一个进程在同一文件夹中的可执行文件 [英] How to start a process in the same folder as its executable

查看:102
本文介绍了如何启动一个进程在同一文件夹中的可执行文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图以编程方式启动应用程序,但它始终运行它我的应用程序的文件夹...例如:



如果我的应用程序位于在C:\MyApp\myapp.exe和其他应用程序是在C:\OtherApp\otherapp.exe,我怎么能启动其他应用程序所驻留,而不是文件夹,在文件夹中的我应用程序驻留



下面是我如何启动其他应用程序:

 私人无效的startApp(OtherApp应用程序)
{
工艺过程=新工艺();
process.StartInfo.FileName = application.FileName;
process.StartInfo.Arguments = application.AppName;
的Process.Start();
}


解决方案

我猜你的意思是<一个HREF =htt​​p://msdn.microsoft.com/en-us/library/system.diagnostics.processstartinfo.workingdirectory.aspx> ProcessStartInfo.WorkingDirectory物业


I'm trying to start an application programatically, but it always runs it in the folder of my application... For example:

If my app is located in C:\MyApp\myapp.exe and the other app is in C:\OtherApp\otherapp.exe, how can I start the other app in the folder in which it resides, rather than in the folder where my app resides?

Here is how I start the other app:

private void StartApp(OtherApp application)
{
    Process process = new Process();
    process.StartInfo.FileName = application.FileName;
    process.StartInfo.Arguments = application.AppName;
    process.Start();
}

解决方案

I guess you mean ProcessStartInfo.WorkingDirectory Property

这篇关于如何启动一个进程在同一文件夹中的可执行文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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