TStringList.SaveToFile

From Soldat Community Wiki
Jump to: navigation, search
procedure SaveToFile(FileName: string)
 FileName: path to a target file

Description

SaveToFile saves the contents of the stringlist to the file with name FileName. It writes the strings to the file, separated by end-of-line markers, so each line in the file will contain 1 string from the stringlist.

Example

script file:

const
  // assuming Sandbox Level < 2
  PATH='myfile.txt';

var
  s: TStringList;

begin
  s := File.CreateStringList();
  s.Append('a');
  s.Append('b');
  s.Append('c');
  WriteLn(s.CommaText);
  // a,b,c

  s.SaveToFile(PATH);

  s.Free;
end.

myfile.txt in soldatserver's root folder:

a
b
c