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

Popular posts from this blog

android - Spacing between the stars of a rating bar? -

aspxgridview - Devexpress grid - header filter does not work if column is initially hidden -

c# - How to execute a particular part of code asynchronously in a class -