我无法在运行时获取应用程序的可执行文件的路径.此应用程序由另一个可执行文件启动,每当我尝试使用Application.ExecutablePath时,我都会获得该应用程序的路径,而不是我的.
Dim aPath1 As String = Application.ExecutablePath()
Dim aPath2 As String = Application.StartupPath()
Run Code Online (Sandbox Code Playgroud)
在C#中它会是
string aPath1 = Application.ExecutablePath;
string aPath2 = Application.StartupPath;
Run Code Online (Sandbox Code Playgroud)
这些都没有给我这个程序的路径,其中这两行被执行,它们只告诉程序启动了什么程序.
非常感谢任何帮助,谢谢你提前.
尝试
Assembly.GetExecutingAssembly().Location
Run Code Online (Sandbox Code Playgroud)
请参阅http://msdn.microsoft.com/en-us/library/system.reflection.assembly.location.aspx
AppDomain.CurrentDomain.BaseDirectory 在大多数情况下,你会得到你想要的东西.
或者,这将为您提供执行代码的程序集的位置:
System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
| 归档时间: |
|
| 查看次数: |
4351 次 |
| 最近记录: |