我已经使用VB创建了一个Windows应用程序.每当执行exe时,我都希望以编程方式获取exe文件的当前目录.
I have created one windows application using VB. Whenever I executing the exe, I want to get the current directory of the exe file programatically.
例如,
现在,我正在执行d:\myApp\test.exe中的exe文件.每当我双击exe文件时,我都想获取exe文件的路径,例如d:\myApp\test.exe.
Now, I am executing the exe file in d:\myApp\test.exe. Whenever I double click the exe file I want to get the path of the exe file like d:\myApp\test.exe.
还,假设我的exe位于CD或任何记忆棒中,它还会获取exe文件的路径吗?
Also, suppose, my exe is in CD or any memory stick, will it also get the path of the exe file?
我不知道这有可能吗?
有什么建议吗?
推荐答案尝试 App.Path .它将为您提供当前的exe路径.要获取exe名称,可以使用 App.EXEName . 请注意,在驱动器的根目录中,App.Path将包含尾随的\,因此需要有条件地添加任何额外的\.
Try App.Path. It will give you the current exe path. To get exe name you can use App.EXEName. Note that App.Path will contain the trailing \ when in the root of a drive so any extra \ will need to be added conditionally.
因此要获取具有exe名称的完整路径,请尝试以下操作:
So to get full path with exe name try this:
App.Path & IIf(Right$(App.Path, 1) <> "\", "\", "") & App.EXEName & ".exe"此外,它还将为您提供CD或任何记忆棒的路径.
Also, It will give you CD or any memory stick's path too.
更多推荐
如何在VB中获取当前可执行文件的完整路径?
发布评论