IFile.OpenTextWriter

Syntax

OpenTextWriter(FileName: String; Truncate: Boolean): ITextWriter;

Parameters

FileName. Path and name of the file to be opened.

Truncate. The parameter that determines whether the file is cleared while opening. True if the file is cleared.

Description

The OpenTextWriter method opens a file for writing in a text format and puts a cursor to the beginning of a file.

Example

Sub UserProc;
Var
    TextW: ITextWriter;
Begin
    If File.Exists("c:\New_folder\1.txt"Then
        TextW := File.OpenTextWriter("c:\New_folder\1.txt"True);
        TextW.Encoding := CodePage.UTF8;
        TextW.WriteDateTime(DateTime.Now);
    End If;
End Sub UserProc;

After executing the example the current date and time converted into a text format are written to the 1.txt file. UTF-8 encoding will be used when working with file. The file is overwritten.

See also:

IFile