System.Classes.TStrings.LoadFromFile
Delphi
procedure LoadFromFile(const FileName: string); overload; virtual;
procedure LoadFromFile(const FileName: string; Encoding: TEncoding); overload; virtual;
C++
virtual void __fastcall LoadFromFile(const System::UnicodeString FileName)/* overload */;
virtual void __fastcall LoadFromFile(const System::UnicodeString FileName, System::Sysutils::TEncoding* Encoding)/* overload */;
Properties
Type | Visibility | Source | Unit | Parent |
---|---|---|---|---|
procedure function |
public | System.Classes.pas System.Classes.hpp |
System.Classes | TStrings |
Description
Fills the string list with the lines of text in a specified file.
LoadFromFile fills the string list of the TStrings object from the file specified by FileName
. LoadFromFile first clears any strings already in the list. Lines in the file are separated by a carriage return and a line feed (#13#10
) on Windows operating systems and a carriage return (#13
) on the OS X operating system. Each line in the file is then appended in the list as a string.
If the Encoding
parameter is not given, then the strings are loaded using the appropriate encoding. The value of the encoding is obtained by calling the GetBufferEncoding routine of the TEncoding class. LoadFromFile then saves the value of the encoding in the Encoding property, to be used if the file is saved.
If the specified file is not found, an EFOpenError is raised.
See Also
- System.Classes.TStrings.Add
- System.Classes.TStrings.LoadFromStream
- System.Classes.TStrings.SaveToFile
- System.Classes.TStrings.Encoding
- System.Classes.TStrings.Strings
- System.Classes.TStrings.Text
- Using TEncoding for Unicode Files