Capacity: Integer;
The Capacity property determines capacity in bytes of memory assigned for a stream.
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 this example, content of the file 1.dat" is read into the stream MStream that is in memory. The "i" variable contains value of memory capacity assigned for a stream.
See also: