|
-
Apr 22nd, 2002, 06:35 PM
#1
Thread Starter
Junior Member
short 8.3 filename from long Filename
Anybody know how to go to the ms-dos filename from a known long filename?
-
Apr 22nd, 2002, 06:54 PM
#2
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:
Private Sub Form_Load()
MsgBox Get_DosFileName("C:\MyFolder\Longfilename.doc")
End Sub
Private Function Get_DosFileName(sPath As String) As String
Dim sFile As String 'File Name
Dim sExt As String 'File extension
sFile = Mid$(sPath, InStrRev(sPath, "\") + 1, InStrRev(sPath, ".") - InStrRev(sPath, "\") - 1)
sExt = Right$(sPath, Len(sPath) - InStrRev(sPath, "."))
Get_DosFileName = Left$(sFile, 6) & "~1." & sExt
End Function
Last edited by Bruce Fox; Apr 22nd, 2002 at 07:29 PM.
-
Apr 22nd, 2002, 07:02 PM
#3
Muck around with this. You should get it.
VB Code:
Private Declare Function GetShortPathName Lib "kernel32" Alias "GetShortPathNameA" (ByVal lpszLongPath As String, ByVal lpszShortPath As String, ByVal lBuffer As Long) As Long
Public Function GetShortPath(strFileName As String) As String
'KPD-Team 1999
'URL: [url]http://www.allapi.net/[/url]
Dim lngRes As Long, strPath As String
'Create a buffer
strPath = String$(165, 0)
'retrieve the short pathname
lngRes = GetShortPathName(strFileName, strPath, 164)
'remove all unnecessary chr$(0)'s
GetShortPath = Left$(strPath, lngRes)
End Function
Private Sub Form_Load()
MsgBox GetShortPath("c:\Program Files\")
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|