如何在VB中获取当前可执行文件的完整路径?

编程入门 行业动态 更新时间:2024-10-25 22:29:05
本文介绍了如何在VB中获取当前可执行文件的完整路径?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我已经使用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中获取当前可执行文件的完整路径?

本文发布于:2023-11-10 02:00:58,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1574041.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:可执行文件   路径   完整   如何在   VB

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!