IFileInfo.OpenTextWriter

Syntax

OpenTextWriter(Truncate: Boolean): ITextWriter;

Parameters

Truncate - a parameter that determines whether the file is cleared while opening. If the value is True the file is cleared.

Description

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

Example

Sub Main;

Var

File1: IFileInfo;

TextW: ITextWriter;

Begin

File1:=New FileInfo.Attach("c:\Work\1.txt");

If File1.Exists Then

TextW:=File1.OpenTextWriter(True);

TextW.WriteDateTime(DateTime.Now);

End If;

Dispose File1;

End Sub Main;

After executing this example, current date and time converted to a text format are written into the file 1.txt. The file is overwritten.

See also:

IFileInfo