WriteDateTime(Value: DateTime);
Value. Dates or time values that must be written.
The WriteDateTime method writes variables of the DateTime type into a text file.
Sub UserProc;
Var
f: IFileStream;
TxtWriter: ITextWriter;
Begin
f := New FileStream.Create("c:\File.txt", FileOpenMode.Create, FileShare.Exclusive);
TxtWriter := New TextWriter.Create(f);
TxtWriter.Encoding := CodePage.UTF8;
TxtWriter.WriteString("Created:");
TxtWriter.WriteDateTime(DateTime.Now);
TxtWriter.Flush;
Dispose f;
End Sub UserProc;
After executing the example a new text file File.txt is created. Creation date and time are written to the file. UTF-8 encoding is used when working with file.
See also: