123 Eng

Engineering the engineers™

Latest Jobs   Forum Map



Source Codes

Engineering Colleges

BE Students

Training  Reports (updated)

Seminar Reports (updated

Placement Papers (updated)


   Computer Science / IT






   CAT / MBA

   GMAT / Foreign MBA

Latest Jobs

Engineering Jobs / Technical Jobs

Management Jobs



Terms of use

Displaying  Source Code(s)  

GetShortPath Function


Description : GetShortPath returns the DOS 8.3 equivalent of an entered path to a file or folder. There is one argument, sPath representing the path to translate to a short path. The path (file or folder) must exist on the server or an error will occur. GetShortPath is most useful with the Shell statement as Shell requires a DOS 8.3 equivalent file path to work properly.

Private Function GetShortPath(ByVal sPath)
Dim re, fso, s, f

Set re = New RegExp
re.ignorecase = True

'determine whether or not this is a file
re.pattern = ".([A-Zd]{1,5})$"

Set fso = CreateObject("Scripting.FileSystemObject")

'if it's a file, grab it. if it's a folder, grab it.
If re.test(sPath) Then

'retrieve handle to the file
Set f = fso.GetFile(sPath)

'retrieve handle to the folder
Set f = fso.GetFolder(sPath)
End If

'get the short path
s = f.ShortPath

'free all object and handle references
Set f = Nothing
Set fso = Nothing
Set re = Nothing

'return short path
GetShortPath = s
End Function


Contribute content or training reports / feedback / Comments
job placement papers
All rights reserved copyright 123ENG