如何在与其可执行文件相同的文件夹中启动一个进程 [英] How to start a process in the same folder as its executable
问题描述
我正在尝试以程序方式启动应用程序,但它总是在我的应用程序的文件夹中运行...例如:
I'm trying to start an application programatically, but it always runs it in the folder of my application... For example:
如果我的应用程序位于在C:\MyApp\myapp.exe中,另一个应用程序在C:\OtherApp\otherapp.exe中,如何在其所在的文件夹中启动其他应用程序,而不是在我的应用程序驻留?
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();
}
推荐答案
我想你的意思是href =http://msdn.microsoft.com/en-us/library/system.diagnostics.processstartinfo.workingdirectory.aspx =noreferrer> ProcessStartInfo.WorkingDirectory属性
I guess you mean ProcessStartInfo.WorkingDirectory Property
这篇关于如何在与其可执行文件相同的文件夹中启动一个进程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!