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 list with the lines of text in a specified file.
Call LoadFromFile to fill the list of the TStrings object from the file specified by FileName
. LoadFromFile first clears any strings already in the list. As indicated by carriage return or linefeed characters, 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.
Note: LoadFromFile uses the Add method to add the strings that are read from the file.
If the specified file is not found, an EFOpenError is raised.
See Also
Code Examples
- PlainTextProperty (Delphi)
- TOpenTextFileDialog (Delphi)
- TStringsEncoding (Delphi)
- PlainText (C++)
- TOpenTextFileDialog (C++)
- TStringsEncoding (C++)