Q: SendTo and short/long filenames? 
Author Message
 Q: SendTo and short/long filenames?

Converting Short Long Filenames to Short:

' Use as follows:
' LongFilename=GetLongFilename(ShortFilename)

Public Function GetLongFilename(FileName As String) As String
    ' Capitalizes the correct parts of the filename and replaces any short
filename with long ones

    Dim CurrentPath As String, Remaining As String
    Dim FirstPart As String, CurrentFolder As String, Start As Integer
    Remaining = FileName
    CurrentPath = vbNullString

    Start = InStr(InStr(FileName, ":\") + 2, FileName, "\")
    If Start > 0 Then
        CurrentPath = Mid$(FileName, 1, Start - 1)
    Else
        CurrentPath = FileName
    End If

    Remaining = FileName
    Do
        FirstPart = ExtractPath(CurrentPath)
        CurrentFolder = ExtractFileName(CurrentPath)
        CurrentPath = FirstPart & "\" & Dir(CurrentPath, vbDirectory)
        If Remaining = FileName Then
            ' First Time
            Remaining = Mid$(Remaining, Len(FirstPart) + 2)
        End If
        Remaining = Mid$(Remaining, Len(CurrentFolder) + 2)
        If Remaining <> vbNullString Then
            CurrentPath = CurrentPath & "\" & ExtractFirstFolder(Remaining)
        End If
    Loop Until Remaining = vbNullString

    If InStr(CurrentPath, ":\") > 0 Then Mid$(CurrentPath, 1, 1) =
UCase$(Mid$(CurrentPath, 1, 1))

    GetLongFilename = CurrentPath
End Function

Public Function ExtractFileName(PathAndFileName As String) As String
    Dim PathName As String, i As Integer
    ExtractFileName = vbNullString
    PathName = Trim$(PathAndFileName)
    For i = Len(PathName) To 1 Step -1
        If Mid$(PathName, i, 1) = "\" Or Mid$(PathName, i, 1) = "/" Then
Exit For
    Next i
    If Len(PathName) > i Then ExtractFileName = Mid$(PathName, i + 1)
End Function

Public Function ExtractPath(PathAndFileName As String) As String
    Dim PathName As String, i As Integer
    ExtractPath = vbNullString
    PathName = Trim$(PathAndFileName)
    For i = Len(PathName) To 1 Step -1
        If Mid$(PathName, i, 1) = "\" Or Mid$(PathName, i, 1) = "/" Then
Exit For
    Next i
    If i > 0 Then ExtractPath = Mid$(PathName, 1, i - 1)
End Function

Public Function ExtractFirstFolder(Path As String) As String
    If InStr(Path, "\") > 0 Then
        ExtractFirstFolder = Mid$(Path, 1, InStr(Path, "\") - 1)
    Else
        ExtractFirstFolder = Path
    End If
End Function

*************************

Note:

If you want to pass the long filename to your program by association in the
registry, enter the commandline value as "c:\filename.exe %l" (lowercase L)



Wed, 24 Oct 2001 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Converting a Long FIleName to it's short equivalent (Both possible shorts)

2. SHORT filename to LONG filename???

3. Short Filename to Long Filename ???

4. Long Filename -> Short Filename

5. SHORT filename to LONG filename???

6. Convert long filenames to short filenames

7. Convert Long Filenames to Short Filenames in VB4 16-Bit

8. Converting long filenames to short filenames in VB4.0 16-bit

9. Short filename to long filename

10. Need to get the short filename from a long filename

11. Converting a Long Filename to Short.?

12. Long filenames VS short

 

 
Powered by phpBB® Forum Software