Overload List
| # | Signature | Description |
|---|---|---|
| 1 | procedure SaveToFile(const FileName: string); overload; | Writes Text to file FileName in Encoding (the encoding of the last load), else DefaultEncoding: SaveToStream on a new file. |
| 2 | procedure SaveToFile(const FileName: string; const Encoding: TEncoding); overload; | Writes Text to file FileName in Encoding: SaveToStream on a new file; nil writes in DefaultEncoding. |
Overload 1: procedure SaveToFile(const FileName: string); overload;
Writes Text to file FileName in Encoding (the encoding of the last load), else DefaultEncoding: SaveToStream on a new file.
| # | Name | Description |
|---|---|---|
| 1 | FileName | The file's name; the file is created anew. |
Result: stored in self (calling object)
Examples
Saved and loaded into another list.
uses Substr, System.SysUtils;
procedure Example;
const FileName = 'SubstringListSave.txt';
var List, Other: TSubstringList;
begin
List := TSubstringList.Create(2);
Other := TSubstringList.Create(2);
try
List.Add('a');
List.Add('b');
List.SaveToFile(FileName);
Other.LoadFromFile(FileName);
Assert(Other.Text = List.Text);
finally
Other.Free;
List.Free;
DeleteFile(FileName);
end;
end;
Overload 2: procedure SaveToFile(const FileName: string; const Encoding: TEncoding); overload;
Writes Text to file FileName in Encoding: SaveToStream on a new file; nil writes in DefaultEncoding.
| # | Name | Description |
|---|---|---|
| 1 | FileName | The file's name; the file is created anew. |
| 2 | Encoding | The encoding to write in; nil writes in DefaultEncoding. |
Result: stored in self (calling object)