Results 1 to 4 of 4
  1. #1
    Silver Lounger
    Join Date
    Jan 2001
    Location
    Northern, California, USA
    Posts
    1,886
    Thanks
    0
    Thanked 0 Times in 0 Posts

    How to get the DOS path for Long filenames

    There has to be a way.. any ideas? <img src=/S/smile.gif border=0 width=15 height=15>

    Drk.
    <IMG SRC=http://www.wopr.com/w3tuserpics/Kel_sig.gif>
    Moderator:<font color=448800> Pix Place, Internet Explorer</font color=448800>
    <small>www.kvisions.com

  2. #2
    Uranium Lounger
    Join Date
    Jan 2001
    Location
    South Carolina, USA
    Posts
    7,295
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: How to get the DOS path for Long filenames

    Open a DOS Window and do a DIR.
    Legare Coleman

  3. #3
    Silver Lounger
    Join Date
    Jan 2001
    Location
    Northern, California, USA
    Posts
    1,886
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: How to get the DOS path for Long filenames

    <img src=/S/bingo.gif border=0 width=15 height=22> I knew that.. <img src=/S/laugh.gif border=0 width=15 height=15>

    Thanks!

    Drk.
    <IMG SRC=http://www.wopr.com/w3tuserpics/Kel_sig.gif>
    Moderator:<font color=448800> Pix Place, Internet Explorer</font color=448800>
    <small>www.kvisions.com

  4. #4
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: How to get the DOS path for Long filenames

    If you mean in VBA:

    Add this at the top of your module:

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

    And add this function somewhere:

    Function GetDOSPath(strLongFileName As String, IsFolder As Boolean) As String
    'Uses Windows' GetShortPathName function to get a DOS-
    'compliant path or file name
    'Created 3/31/99 with help from Getz & Gilbert

    Dim strBuffer As String '8.3 file name/buffer
    Dim lngPathLen As Long 'length of path

    'preallocate space for return from Win32 API fxn
    strBuffer = Space(260)

    'call function
    lngPathLen = GetShortPathName(strLongFileName, _
    strBuffer, Len(strBuffer))

    ' If not a blank string then extract DOS path
    If lngPathLen > 0 Then
    GetDOSPath = Left(strBuffer, lngPathLen)
    'following added 5/2/99 just to be sure
    If IsFolder And (Right(GetDOSPath, 1) <> "") Then
    GetDOSPath = GetDOSPath & ""
    End If
    Else
    GetDOSPath = vbNullString
    End If
    End Function

    You might not need to parse a pure folder name, but that's an option. Hope this helps.

Posting Permissions

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