System.IOUtils.TFile.ReadAllText
Delphi
class function ReadAllText(const Path: string): string; overload; inline; static;
class function ReadAllText(const Path: string; const Encoding: TEncoding): string; overload; inline; static;
C++
static System::UnicodeString __fastcall ReadAllText(const System::UnicodeString Path)/* overload */;
static System::UnicodeString __fastcall ReadAllText(const System::UnicodeString Path, System::Sysutils::TEncoding* const Encoding)/* overload */;
Properties
Type | Visibility | Source | Unit | Parent |
---|---|---|---|---|
function | public | System.IOUtils.pas System.IOUtils.hpp |
System.IOUtils | TFile |
Description
Returns the contents of a textual file as a string.
ReadAllText reads the contents of a textual file and returns a string containing the text read from the file.
ReadAllText, with one parameter, first reads the preamble bytes from the beginning of the Path
textual file. Then ReadAllText skips the preamble bytes and reads the contents of the textual file beginning from this offset.
ReadAllText returns a string containing the text read from the file.
If the Path
file does not contain a byte order mark for one of the standard encodings, the Default standard encoding is accepted and corresponding number of bytes is skipped.
ReadAllText, with two parameters, first reads from the beginning of the Path
textual file and skips the number of bytes corresponding to the preamble of the specified Encoding
. Then ReadAllText reads the contents of the textual file beginning from this offset and returns a string containing the text read from the file.
ReadAllText has the following parameters:
Path
is the path to the file.Encoding
is the encoding of the text contained within thePath
file.
See Also
- System.SysUtils.TEncoding.GetBufferEncoding
- System.IOUtils.TFile.ReadAllBytes
- System.IOUtils.TFile.ReadAllLines