Results 1 to 3 of 3

Thread: short 8.3 filename from long Filename

  1. #1

    Thread Starter
    Junior Member dcjonas's Avatar
    Join Date
    Jan 2002
    Posts
    25

    short 8.3 filename from long Filename

    Anybody know how to go to the ms-dos filename from a known long filename?

  2. #2
    INXSIVE Bruce Fox's Avatar
    Join Date
    Sep 2001
    Location
    Melbourne, Australia
    Posts
    7,429
    If the File is unique, ie the only one of that name, then
    can't u just truncate the FileName and append "~1.txt"
    (or what ever the file extension is)?

    If ur just concerned with converting a FileName to DosName then:
    VB Code:
    1. Private Sub Form_Load()
    2.     MsgBox Get_DosFileName("C:\MyFolder\Longfilename.doc")
    3. End Sub
    4.  
    5. Private Function Get_DosFileName(sPath As String) As String
    6.     Dim sFile As String 'File Name
    7.     Dim sExt As String 'File extension
    8.  
    9.     sFile = Mid$(sPath, InStrRev(sPath, "\") + 1, InStrRev(sPath, ".") - InStrRev(sPath, "\") - 1)
    10.     sExt = Right$(sPath, Len(sPath) - InStrRev(sPath, "."))
    11.  
    12.    Get_DosFileName = Left$(sFile, 6) & "~1." & sExt
    13. End Function
    Last edited by Bruce Fox; Apr 22nd, 2002 at 07:29 PM.

  3. #3
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333
    Muck around with this. You should get it.
    VB Code:
    1. Private Declare Function GetShortPathName Lib "kernel32" Alias "GetShortPathNameA" (ByVal lpszLongPath As String, ByVal lpszShortPath As String, ByVal lBuffer As Long) As Long
    2. Public Function GetShortPath(strFileName As String) As String
    3.     'KPD-Team 1999
    4.     'URL: [url]http://www.allapi.net/[/url]
    5.     'E-Mail: [email][email protected][/email]
    6.     Dim lngRes As Long, strPath As String
    7.     'Create a buffer
    8.     strPath = String$(165, 0)
    9.     'retrieve the short pathname
    10.     lngRes = GetShortPathName(strFileName, strPath, 164)
    11.     'remove all unnecessary chr$(0)'s
    12.     GetShortPath = Left$(strPath, lngRes)
    13. End Function
    14. Private Sub Form_Load()
    15.     MsgBox GetShortPath("c:\Program Files\")
    16. End Sub

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