Re: How to get long filename from short filename?

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



Paul Emmons (pemmons@xxxxxxxxxxxx) schrieb/wrote:

> Function LongName(ShortName)
> dim oFS, oFI
> set oFS = CreateObject("Scripting.FileSystemObject")
> set oFi = oFS.GetFile(ShortName)
> With CreateObject("Wscript.Shell")
> With .CreateShortcut("dummy.lnk")
> .TargetPath = oFi
> LongName = .TargetPath
> End with
> End with
> set oFS = nothing
> set oFi = nothing
> End Function

A bit more compact (Const used to avoid long lines):

' returns long path/filename from any filename (long or short)
' regardless whether path is given or missing
'
Function LongName(strFName)
Const ScFSO = "Scripting.FileSystemObject"
Const WScSh = "WScript.Shell"
With WScript.CreateObject(WScSh).CreateShortcut("dummy.lnk")
.TargetPath = CreateObject(ScFSO).GetFile(strFName)
LongName = .TargetPath
End With
End Function

--
Gruß, | Bitte in der NG antworten | Win98-Tipps:
Regards, Andreas | Please reply to the NG | http://a-kaestner.de
==================*===========================*=======================72
OE-QuoteFix 1.19.2: http://home.in.tum.de/~jain/software/oe-quotefix/

.