help files
Z505 | PasWiki | FUQ | Search | Main Docs | API Guide



[Overview][Constants][Types][Classes][Procedures and functions][Variables] Reference for unit 'Classes' (#rtl)

TMemoryStream.LoadFromStream

Loads the contents of a stream into memory.

Declaration

Source position: classesh.inc line 704

public procedure TMemoryStream.LoadFromStream(

  Stream: TStream

);

Description

LoadFromStream loads the contents of Stream into the memorybuffer of the stream. Any previous contents of the memory stream are overwritten. Memory is allocated as needed.

Remark:

The LoadFromStream uses the Size property of Stream to determine how much memory must be allocated. Some streams do not allow the stream size to be determined, so care must be taken when using this method.

This method will work much faster than the use of the TStream.CopyFrom method:

Seek(0,soFromBeginning);
  CopyFrom(Stream,Stream.Size);

because the CopyFrom method copies the contents in blocks, while LoadFromStream reads the contents of the stream as one big block.

Errors

If an error occurs when reading from the stream, an EStreamError may occur.

See also

TStream.CopyFrom

  

Copy data from one stream to another

TMemoryStream.LoadFromFile

  

Loads the contents of a file into memory.

Notes

 No notes exist for this page yet. 





lufdoc, Powtils, fpc, freepascal, delphi, kylix, c/c++, mysql, cgi web framework docs, Z505