Show: Delphi C++
Display Preferences

System.Classes.TStrings.LoadFromFile

From RAD Studio API Documentation
Jump to: navigation, search

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.

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

Personal tools
In Other Languages
Previous Versions
Assistance