How can I retrieve long file and path names from short file and path names ?
I have a problem with my app. When I double click the associated file it only retrieve the shorth path name. WHY ??
Thanks in advance !
Printable View
How can I retrieve long file and path names from short file and path names ?
I have a problem with my app. When I double click the associated file it only retrieve the shorth path name. WHY ??
Thanks in advance !
Public Function GetLongName(sShortName As String) As String
Dim sTemp As String
Dim sNew As String
Dim iHasBS As Integer
Dim iBS As Integer
If Len(sShortName) = 0 Then Exit Function
sTemp = sShortName
If Right$(sTemp, 1) = "\" Then
sTemp = Left$(sTemp, Len(sTemp) - 1)
iHasBS = True
End If
On Error GoTo MSGLFNnofile
If InStr(sTemp, "\") Then
sNew = ""
Do While InStr(sTemp, "\")
If Len(sNew) Then
sNew = Dir$(sTemp, 54) & "\" & sNew
Else
sNew = Dir$(sTemp, 54)
If sNew = "" Then
GetLongName = sShortName
Exit Function
End If
End If
On Error Resume Next
For iBS = Len(sTemp) To 1 Step -1
If ("\" = Mid$(sTemp, iBS, 1)) Then
'found it
Exit For
End If
Next iBS
sTemp = Left$(sTemp, iBS - 1)
Loop
sNew = sTemp & "\" & sNew
Else
sNew = Dir$(sTemp, 54)
End If
MSGLFNresume:
If iHasBS Then
sNew = sNew & "\"
End If
GetLongName = sNew
Exit Function
MSGLFNnofile:
sNew = ""
Resume MSGLFNresume
End Function