Overload List
| # | Signature | Description |
|---|---|---|
| 1 | procedure LoadFromFile(const FileName: string); overload; | Replaces the items with the lines of file FileName: LoadFromStream on the file, in the encoding its byte order mark names, else DefaultEncoding. |
| 2 | procedure LoadFromFile(const FileName: string; const Encoding: TEncoding); overload; | Replaces the items with the lines of file FileName in Encoding; nil reads in the encoding the byte order mark names, else DefaultEncoding. |
Overload 1: procedure LoadFromFile(const FileName: string); overload;
Replaces the items with the lines of file FileName: LoadFromStream on the file, in the encoding its byte order mark names, else DefaultEncoding.
| # | Name | Description |
|---|---|---|
| 1 | FileName | The file's name. |
Result: stored in self (calling object)
Examples
A file written and read back.
uses Substr, System.SysUtils;
procedure Example;
const FileName = 'SubstringListLoad.txt';
var List: TSubstringList;
begin
List := TSubstringList.Create(4);
try
List.Add('first');
List.Add('second');
List.SaveToFile(FileName, TEncoding.UTF8);
List.LoadFromFile(FileName);
Assert((List.Count = 2) and (List[1] = 'second'));
Assert(List.Encoding = TEncoding.UTF8);
finally
List.Free;
DeleteFile(FileName);
end;
end;
Overload 2: procedure LoadFromFile(const FileName: string; const Encoding: TEncoding); overload;
Replaces the items with the lines of file FileName in Encoding; nil reads in the encoding the byte order mark names, else DefaultEncoding.
| # | Name | Description |
|---|---|---|
| 1 | FileName | The file's name. |
| 2 | Encoding | The encoding to read the file in; nil as LoadFromFile(FileName). |
Result: stored in self (calling object)