The following code illustrates the use of the
ShortPath property with a File object:
JScript
function ShowShortPath(filespec)
{
var fso, f, s;
fso = new ActiveXObject("Scripting.FileSystemObject");
f = fso.GetFile(filespec);
s = "The short path for " + "" + f.Name;
s += "" + "<br>";
s += "is: " + "" + f.ShortPath + "";
return(s);
}
VBScript
Function ShowShortPath(filespec)
Dim fso, f, s
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.GetFile(filespec)
s = "The short path for " & UCase(f.Name) & "<BR>"
s = s & "is: " & f.ShortPath
ShowShortPath = s
End Function
PowerBASIC
FUNCTION ShowShortPath (BYVAL filespec AS STRING) AS STRING
LOCAL fso AS IFileSystem
LOCAL f AS IFile
LOCAL s AS STRING
fso = NEWCOM "Scripting.FileSystemObject"
f = fso.GetFile(UCODE$(filespec))
s = "The short path for " & ACODE$(f.Name) & $CRLF
s = s & "is: " & ACODE$(f.ShortPath)
FUNCTION = s
END FUNCTION