且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

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

更新时间:2021-08-15 02:12:49

尝试 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.