Create(Stream: IIOStream);
Stream. The stream, to which text data is written.
The Create constructor creates an object that enables the user to write data into a text file.
Specify the stream connected with the place, to which text data is written, as a value of the Stream parameter. Initialize the object of one of the following classes and specify it as a value of the Stream parameter:
FileStream. The stream connected with the file on the hard drive.
MemoryStream. The stream in the computer memory.
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.WriteLnString("***File Info***");
TxtWriter.WriteString("Created:"); TxtWriter.WriteLnDateTime(DateTime.Now);
TxtWriter.WriteString("Company:"); TxtWriter.WriteChar(#169); TxtWriter.WriteLnString("New Line");
//...
TxtWriter.Flush;
Dispose f;
End Sub UserProc;
On executing the example the new text file File.txt is created. The specified character string is written into this file.
See also: