Kir*_*ril 9 c# directory executable process
我正在尝试以编程方式启动应用程序,但它始终在我的应用程序的文件夹中运行...例如:
如果我的应用程序位于C:\ MyApp\myapp.exe而其他应用程序位于C:\ OtherApp\otherapp.exe中,如何在其所在的文件夹中启动其他应用程序,而不是在其中的文件夹中我的应用程序驻留?
以下是我启动其他应用的方法:
private void StartApp(OtherApp application)
{
Process process = new Process();
process.StartInfo.FileName = application.FileName;
process.StartInfo.Arguments = application.AppName;
process.Start();
}
Run Code Online (Sandbox Code Playgroud)
只需设置WorkDirectory属性即可.
process.StartInfo.WorkingDirectory = Path.GetDirectoryName(application.Filename);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
8922 次 |
| 最近记录: |