Results 1 to 2 of 2

Thread: Long file names?

  1. #1

    Thread Starter
    Member
    Join Date
    Nov 1999
    Location
    Singapore
    Posts
    32

    Post

    Hi, How do I access files with LFNs? I always end up with an error.
    Thanks.

  2. #2
    Serge's Avatar
    Join Date
    Feb 1999
    Location
    Scottsdale, Arizona, USA
    Posts
    2,744

    Post

    You can convert long file names to short windows filenames (i.e. C:\Progra~1 etc)

    Code:
    Private Declare Function GetShortPathName Lib "kernel32" Alias "GetShortPathNameA" (ByVal lpszLongPath As String, ByVal lpszShortPath As String, ByVal cchBuffer As Long) As Long
    
    Function ConverLongFileName(pstrFileName As String) As String
        Dim strBuffer As String
        Dim lRet As Long
        strBuffer = Space(255)
        lRet = GetShortPathName(pstrFileName, strBuffer, Len(strBuffer))
        If lRet = 0 Then
            ConverLongFileName = pstrFileName
        Else
            ConverLongFileName = Left(strBuffer, lRet)
        End If
    End Function
    Usage: ConverLongFileName FileToConvert

    Sample:

    Dim strFile As String
    strFile = ConverLongFileName("C:\WINNT\Media\The Microsoft Sound.wav")



    strFile in my case would be: C:\WinNT\Media\THEMIC~1.WAV

    ------------------

    Serge

    Software Developer
    [email protected]
    [email protected]
    ICQ#: 51055819


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