|
-
Feb 2nd, 2004, 09:03 PM
#1
Thread Starter
Frenzied Member
[VB] Get longfilename
'*Gets long filename from ms-dos filename!
Function GetLongFilename(strShortName As String) As String
On Error Resume Next
Dim strTemp As String 'Temporary String Holder
Dim strNew As String 'Hold New String
Dim intHasBS As Integer 'Has Back Slash Flag
Dim intBS As Integer 'Back Slash Position
If Len(strShortName) = 0 Then Exit Function
strTemp = strShortName
If Right$(strTemp, 1) = "\" Then
strTemp = Left$(strTemp, Len(strTemp) - 1)
intHasBS = True
End If
On Error GoTo MSGLFNnofile
If InStr(strTemp, "\") Then
strNew = ""
Do While InStr(strTemp, "\")
If Len(strNew) Then
strNew = Dir$(strTemp, 54) & "\" & strNew
Else
strNew = Dir$(strTemp, 54)
If strNew = "" Then
GetLongFilename = strShortName
Exit Function
End If
End If
On Error Resume Next
For intBS = Len(strTemp) To 1 Step -1
If ("\" = Mid$(strTemp, intBS, 1)) Then
'found it
Exit For
End If
Next intBS
strTemp = Left$(strTemp, intBS - 1)
Loop
strNew = strTemp & "\" & strNew
Else
strNew = Dir$(strTemp, 54)
End If
MSGLFNresume:
If intHasBS Then
strNew = strNew & "\"
End If
GetLongFilename = strNew
Exit Function
MSGLFNnofile:
strNew = ""
Resume MSGLFNresume
End Function
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|