Mega Code Archive

 
Categories / Delphi / Examples
 

Textfiles

OPENING A TEXT FILE, AND WRITING IT'S CONTENTS TO ANOTHER TEXT FILE... Example uses Dialogs; var F, FTwo: System.TextFile; Ch: Char; Buf: array[1..4095] of Char; { 4K buffer } begin if OpenDialog1.Execute then begin AssignFile(F, ParamStr(1)); { Bigger buffer for faster reads } SetTextBuf(F, Buf); Reset(F); { Dump text file into another file } AssignFile(FTwo, 'WOOF.DOG'); Rewrite(FTwo); while not Eof(f) do begin Read(F, Ch); Write(FTwo, Ch); end; System.CloseFile(F); System.CloseFile(FTwo); end; end;