如何在 VBScript 中获取文件的完全限定路径? [英] How to get the fully qualified path for a file in VBScript?
问题描述
我正在使用 Shell.Application
对象,它允许我编写 zip 文件的脚本创建.
I am using the Shell.Application
object, which allows me to script creation of a zip file.
但为了使其工作,我需要 zip 文件的完整路径.File.zip
不起作用.我需要 c: hefullpathfile.zip
,即使脚本在找到文件的同一目录中运行.
But in order for this to work, I need to full path of the zip file. File.zip
doesn't work. I need c: hefullpathfile.zip
, even if the script is running within the same directory where the file is found.
如何在 VBScript 中获取文件的完整路径?
How can I get the full path of a file in VBScript?
类似于 cmd.exe shell 中的 %~fI
扩展.
Something like the %~fI
expansion in the cmd.exe shell.
推荐答案
On Scripting.FileSystemObject,有一种方法叫做 GetAbsolutePathName 就是这样做的.
On Scripting.FileSystemObject, there's a method called GetAbsolutePathName that does this.
这对我有用:
Dim folderName
folderName = "...."
Dim fso
Set fso = CreateObject("Scripting.FileSystemObject")
Dim fullpath
fullpath = fso.GetAbsolutePathName(folderName)
WScript.Echo "folder spec: " & folderName
WScript.Echo "fullpath: " & fullpath
这篇关于如何在 VBScript 中获取文件的完全限定路径?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!