Show contents 

IO > IO Assembly Interfaces > IFileInfo > IFileInfo.OpenTextReader

IFileInfo.OpenTextReader

Syntax

OpenTextReader: ITextReader;

Description

The OpenTextReader method opens a file for reading in a text format.

Example

Sub UserProc;
Var
    File1: IFileInfo;
    TextR: ITextReader;
    d: DateTime;
Begin
    File1 := New FileInfo.Attach("c:\Work\1.txt");
    If File1.Exists Then
        TextR := File1.OpenTextReader;
        TextR.Encoding := CodePage.UTF8;
        d := TextR.ReadDateTime;
    End If;
    Dispose File1;
End Sub UserProc;

After executing the example date and time are read from the 1.txt file into the "d" variable. UTF-8 encoding is used when working with file.

See also:

IFileInfo