Results 1 to 5 of 5

Thread: DOS File Names

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Feb 2001
    Location
    Crossroads
    Posts
    3,046

    DOS File Names

    This is related to

    http://forums.vb-world.net/showthrea...threadid=93712

    but I didnt want to hijack the thread.

    I know from the above thread that you can convert a long file name to a dos file name.

    Is there a way to convert a dos file name to a long file name (assuming there is a corresponding long name)?

    Thanks

  2. #2
    PowerPoster
    Join Date
    Jul 1999
    Posts
    5,923
    Yep, the GetFullPathName API...
    VB Code:
    1. Declare Function GetFullPathName Lib "kernel32" Alias "GetFullPathNameA" (ByVal lpFileName As String, ByVal nBufferLength As Long, ByVal lpBuffer As String, ByVal lpFilePart As String) As Long
    http://www.allapi.net/api/api158.php

  3. #3

    Thread Starter
    PowerPoster
    Join Date
    Feb 2001
    Location
    Crossroads
    Posts
    3,046
    Thanks!

    Cant seem to get a test to work. Any idea whats wrong?

    VB Code:
    1. Private Declare Function GetFullPathName Lib "kernel32" _
    2. Alias "GetFullPathNameA" (ByVal lpFileName As String, _
    3. ByVal nBufferLength As Long, ByVal lpBuffer As String, _
    4. ByVal lpFilePart As String) As Long
    5.  
    6. Private Sub Command2_Click()
    7.     Dim Buffer As String, Ret As Long
    8.     Buffer = Space(255)
    9.     Ret = GetFullPathName("C:\MYDOCU~1\BOOK1.XLS", 255, Buffer, "")
    10.     Buffer = Left(Buffer, Ret)
    11.     Text4.Text = Buffer
    12. End Sub

  4. #4
    PowerPoster
    Join Date
    Jul 1999
    Posts
    5,923
    Try this example...
    VB Code:
    1. Public Declare Function GetLongPathName Lib "kernel32" Alias "GetLongPathNameA" (ByVal lpszShortPath As String, ByVal lpszLongPath As String, ByVal cchBuffer As Long) As Long
    2.  
    3.  
    4. Public Function GetLongFilename(ByVal sShortFilename As String) As String
    5.     Dim lRet As Long
    6.     Dim sLongFilename As String
    7.     sLongFilename = String$(1024, " ")
    8.     lRet = GetLongPathName(sShortFilename, sLongFilename, Len(sLongFilename))
    9.    
    10.     If lRet > Len(sLongFilename) Then
    11.         sLongFilename = String$(lRet + 1, " ")
    12.         lRet = GetLongPathName(sShortFilename, sLongFilename, Len(sLongFilename))
    13.     End If
    14.    
    15.     If lRet > 0 Then
    16.         GetLongFilename = Left$(sLongFilename, lRet)
    17.     End If
    18.    
    19. End Function
    Courtesy of Matt...

  5. #5

    Thread Starter
    PowerPoster
    Join Date
    Feb 2001
    Location
    Crossroads
    Posts
    3,046
    Works great!

    Thanks Chrijk (and Matt)!!!!!!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width