VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Get a long file name from a short file name

by Anonymous (267 Submissions)
Category: Files/File Controls/Input/Output
Compatability: Visual Basic 5.0
Difficulty: Unknown Difficulty
Originally Published: Tue 16th February 1999
Date Added: Mon 8th February 2021
Rating: (1 Votes)

Get a long file name from a short file name

Rate Get a long file name from a short file name



Public Function GetLongFilename(ByVal sShortName As String) As String

Dim sLongName As String
Dim sTemp As String
Dim iSlashPos As Integer

'Add \ to short name to prevent Instr from failing
sShortName = sShortName & "\"
'Start from 4 to ignore the "[Drive Letter]:\" characters
iSlashPos = InStr(4, sShortName, "\")
'Pull out each string between \ character for conversion
While iSlashPos
    sTemp = Dir(Left$(sShortName, iSlashPos - 1), vbNormal + vbHidden + vbSystem + vbDirectory)
    If sTemp = "" Then            'Error 52 - Bad File Name or Number
        GetLongFilename = ""
        Exit Function
    End If
    sLongName = sLongName & "\" & sTemp
    iSlashPos = InStr(iSlashPos + 1, sShortName, "\")
Wend
'Prefix with the drive letter
GetLongFilename = Left$(sShortName, 2) & sLongName

End Function

Download this snippet    Add to My Saved Code

Get a long file name from a short file name Comments

No comments have been posted about Get a long file name from a short file name. Why not be the first to post a comment about Get a long file name from a short file name.

Post your comment

Subject:
Message:
0/1000 characters