ITextReader.ReadToEnd

Syntax

ReadToEnd: String;

Description

The ReadToEnd method reads a text file as one character string.

Example

Sub UserProc;
Var
    File1: IFileInfo;
    TextR: ITextReader;
    s: String;
Begin
    File1 := New FileInfo.Attach("c:\New_folder\1.txt");
    If File1.Exists Then
        TextR := File1.OpenTextReader;
        TextR.Encoding := CodePage.UTF8;
        s := TextR.ReadToEnd;
    End If;
    Dispose File1;
End Sub UserProc;

After executing the example, the 1.txt file is read into the "s" variable. UTF-8 encoding is used when working with file.

See also:

ITextReader