2014-09-28 29 views
0

我知道有很多关于这个主题的问题,但我回顾了他们,我找不到我需要的东西。运行一个exe文件依赖关系VB.Net

我需要在VB.Net中运行一个exe文件,但该exe文件需要exe文件夹中的一些文件。当我尝试使用ShellProcess.Start()运行exe文件时,exe会在我的应用程序文件夹中查找这些文件(并引发错误),而不是exe原始文件夹。我无法移动我的应用程序exe或外部exe文件。

+0

你指从Visual Studio中运行的程序进行调试或在真实deployement运行最后编译的exe?你在说什么文件? – Alejandro 2014-09-28 18:39:28

回答

4

你试过Directory.SetCurrentDirectory方法?它将应用程序的当前工作目录设置为指定的目录。在调用之前使用要执行的应用程序的路径更改下面的示例。

Imports System 
Imports System.IO 

Directory.SetCurrentDirectory("C:\test") 
Console.WriteLine("Current directory: {0}", Directory.GetCurrentDirectory()) 
'Execute an application from C:\test 

输出:

Current directory: C:\test 
+0

工作完美!谢谢! – Lolrapa 2014-09-28 18:45:17

0

您可能能够使用Windows启动路径:

exePath = System.Windows.Forms.Application.StartupPath