IMemoryStream.ToString

Syntax

ToString: String;

Description

The ToString method converts a stream contents into a character string transfer data between streams.

Comments

The value that was obtained as the result of this method may be used to restore data in a stream by the Parse method.

Example

Sub UserProc;
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 UserProc;

After executing the example the contents of the 1.dat file is read into the MStream stream, and the "s" variable contains stream contents converted into a string.

See also:

IMemoryStream