IMemoryStream.Capacity

Syntax

Capacity: Integer;

Description

The Capacity property determines capacity in bytes of memory assigned for a stream.

Example

Sub Main;

Var

File1: IFileInfo;

BinR: IBinaryReader;

MStream: IMemoryStream;

i: Integer;

Begin

MStream:=New MemoryStream.Create;

File1:=New FileInfo.Attach("c:\New_folder\1.dat");

If File1.Exists Then

BinR:=File1.OpenBinaryReader;

For i:=0 To File1.Size-1 Do

MStream.WriteByte(BinR.Stream.ReadByte);

End For;

i:=MStream.Capacity;

End If;

Dispose File1;

Dispose MStream;

End Sub Main;

After executing the example the contents of the 1.dat file is read into the MStream stream that is in memory. The "i" variable contains value of memory capacity assigned for a stream.

See also:

IMemoryStream