Visual Basic Programming Code Examples Visual Basic > Files Directories Drives Code Examples Get the shortfilename (8.3) Get the shortfilename (8.3) 'make a form with a drive-control, dir-control, filelist-control and a label Declare Function GetShortPathName Lib "kernel32" Alias "GetShortPathNameA" (ByVal lpszLongPath As String, ByVal lpszShortPath As String, ByVal cchBuffer As Long) As Long Private sub Dir1_Change() File1 = Dir1.Path End Sub Private sub Drive1_Change() Dir1 = Drive1 End Sub Private sub File1_Click() Label1.Caption = GetShortFileName(Dir1 & "\" & File1) End Sub Public Function GetShortFileName(ByVal FileName As String) As String 'converts a long file and path name to old dos format 'PARAMETERS ' FileName = the path or filename to convert 'RETURNS ' String = the dos compatible name for that particular FileName dim rc As Long dim ShortPath As String Const PATH_LEN& = 164 'get the short filename ShortPath = String$(PATH_LEN + 1, 0) rc = GetShortPathName(FileName, ShortPath, PATH_LEN) GetShortFileName = Left$(ShortPath, rc) End Function Return