运行应用程序的可执行目录?

运行应用程序的可执行目录?

问题描述:

我需要从以下位置获取运行我的应用程序的路径(而非可执行文件):

I need to get the path (not the executable) where my application is running from:

System.AppDomain.CurrentDomain.BaseDirectory()

当我使用&我的本地计算机上的 /images/image.jpg工作正常,但是当我在另一台计算机上安装该应用程序时,它说找不到文件,并且还有很多额外的路径信息。

When I run the above statement with & "/images/image.jpg" on my local machine it works fine but when I install the application on another machine it says it cannot find the file and there is a lot of extra path information some.

我只需要应用运行的目录。我正在使用Visual Studio 2008在VB.NET中进行编码。

I just need the directory of where the app is running. I am coding in VB.NET with Visual Studio 2008.

谢谢!

Dim strPath As String = System.IO.Path.GetDirectoryName( _
    System.Reflection.Assembly.GetExecutingAssembly().CodeBase)

来自如何:确定执行应用程序的路径(MSDN)