From: mayakron@tiscalinet.it Subject: How do I convert path to DOS path? Date: 02 May 1999 00:00:00 GMT Message-ID: <7ggrnu$9ur$1@aquila.tiscalinet.it> Organization: TISCALI S.p.A. Newsgroups: alt.comp.lang.borland-delphi ReplyTo: mayakron@tiscalinet.it >How do I convert paths to DOS paths? >(c:\program files\myfile.txt --> C:\PROGRA~1\MYFILE.TXT) If the file (or directory) really exists on a drive you can do it this way: function GetDosName (FileName:string): string; var D:TSearchRec; begin FindFirst(FileName,faAnyFile,D); if (D.FindData.cAlternateFileName <> '') then GetDosName:=D.FindData.cAlternateFileName else GetDosName:=D.Name; FindClose(D); end; function PathToDOSPath (Path:string): string; var j:integer; X:string; begin X:=Copy(Path,1,2); for j:=4 to Length(Path) do if (Path[j] = '\') then X:=X+'\'+GetDosName(Copy(Path,1,j-1)); PathToDosPath:=X+'\'+GetDosName(Path); end; The last function can convert files & directories like "C:\Windows\Sportster 14400 Fax.log" --> "C:\Windows\Sports~1.log" and "C:\Windows\Termporary Internet Files" --> "C:\Windows\Tempor~1". e-ciao, by Mayakron