How to save string into text files in Delphi? -
what easiest way create , save string .txt
files?
use tstringlist
.
uses classes, dialogs; // classes tstrings, dialogs showmessage var lines: tstrings; line: string; filename: string; begin filename := 'test.txt'; lines := tstringlist.create; try lines.add('first line'); lines.add('second line'); lines.savetofile(filename); lines.loadfromfile(filename); line in lines showmessage(line); lines.free; end; end;
also savetofile
, loadfromfile
can take additional encoding in delphi 2009 , newer set text encoding (ansi, utf-8, utf-16, utf-16 big endian).
Comments
Post a Comment