ToString: String;
The ToString method converts content of a stream to a character string to carry data between streams.
The value that was received as the result of this method may be used to restore data in a stream by the Parse method.
Sub Main;
Var
File1: IFileInfo;
BinR: IBinaryReader;
MStream: IMemoryStream;
i: Integer;
s: String;
Begin
MStream:=New MemoryStream.Create;
File1:=New FileInfo.Attach("c:\Work\1.dat");
If File1.Exists Then
BinR:=File1.OpenBinaryReader;
For i:=0 To File1.Size-1 Do
MStream.WriteByte(BinR.Stream.ReadByte);
End For;
s:=MStream.ToString;
End If;
Dispose File1;
Dispose MStream;
End Sub Main;
After executing this example, content of the file 1.dat is read into the stream MStream and the "s" variable contains stream content converted to a string mode.
See also: