Results 1 to 5 of 5

Thread: LONG FILENAMES

  1. #1

    Thread Starter
    Member
    Join Date
    Sep 1999
    Location
    UK
    Posts
    45

    Post

    I've got a program that doesn't open files with excessively long filenames.

    Is there a way of finding out what the actual 8.3 character filename is...

    (i.e. "longfi~1.jpg" instead of "long filename.jpg")

  2. #2
    Frenzied Member Buzby's Avatar
    Join Date
    Jan 1999
    Location
    UK
    Posts
    1,670

    Post

    Type this in a module;

    Private Declare Function GetShortPathName Lib "kernel32" Alias "GetShortPathNameA" (ByVal lpszLongPath As String, ByVal lpszShortPath As String, ByVal lBuffer As Long) As Long

    Function GetShortPath(strFilename As String) As String
    Dim lngres As Long
    Dim strPath As String
    strPath = String$(165, 0)
    lngres = GetShortPathName(strFilename, strPath, 164)
    GetShortPath = Left$(strPath, lngres)
    End Function

    Then use

    ShortFileName = GetShortPath("this is the long filename.doc")

    Voila.

    'Buzby'
    Visual Basic Developer
    "I'm moving to Theory. Everything works there."

  3. #3

    Thread Starter
    Member
    Join Date
    Sep 1999
    Location
    UK
    Posts
    45

    Post

    Cheers Buzby...

    Any ideas of how to get it to work in NT4 aswell?

    Ta!

    Stevie P

  4. #4
    Frenzied Member Buzby's Avatar
    Join Date
    Jan 1999
    Location
    UK
    Posts
    1,670

    Post

    I suspect the only difference is the API call declaration - check out www.vbapi.com for more info.
    'Buzby'
    Visual Basic Developer
    "I'm moving to Theory. Everything works there."

  5. #5
    Guest

    Post

    What is the exact path you are sending to the function?

    Cause it works for me

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