Visual Basic Programming Code Examples Visual Basic > Files Directories Drives Code Examples Retrieve the old dos filenames from the Win95 or Win98 Long filenames Retrieve the old dos filenames from the Win95 or Win98 Long filenames 'Here's a code snippet to retrieve the old dos filenames 'from the Win95 or Win98 Long filenames. Occasionally, 'you may need this function. 'For example: ' C:\MyLongestPath\MyLongerPath\MyFilename.txt 'would return as ' C:\Mylong~1\MyLong~2\Myfile~1.txt 'Put the declaration in a .bas module Declare Function GetShortPathName Lib "kernel32" Alias _ "GetShortPathNameA" (ByVal lpszLongPath As String, _ ByVal lpszShortPath As String, ByVal cchBuffer As Long) As Long 'Next comes the function (Place in a module): Public Function GetDosPath(LongPath As String) As String Dim s As String Dim i As Long Dim PathLength As Long i = Len(LongPath) + 1 s = String(i, 0) PathLength = GetShortPathName(LongPath, s, i) GetDosPath = Left$(s, PathLength) End Function 'Lastly call it like this: DosPathName = GetDosPath(Long Path Goes in here)