如何在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:\the\full\path\file.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:\the\full\path\file.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.
推荐答案
在 Scripting.FileSystemObject ,有一种叫做
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屋!