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

# TCustomMemoryStream.SaveToStream

Writes the contents of the memory stream to another stream.

## Declaration

`public procedure TCustomMemoryStream.SaveToStream(`
`Stream: TStream`
`);`

## Description

SaveToStream writes the contents of the memory stream to Stream. The content of Stream is not cleared first. The current position of the memory stream is not changed by this action.

Remark: | This method will work much faster than the use of the TStream.CopyFrom method:
    Seek(0,soFromBeginning);
      Stream.CopyFrom(Self,Size);
because the CopyFrom method copies the contents in blocks, while SaveToStream writes the contents of the memory as one big block.

## Errors

If an error occurs when writing to Stream an EStreamError exception will be raised.

## See also

TCustomMemoryStream.SaveToFile |  | Writes the contents of the stream to a file.
TStream.CopyFrom |  | Copy data from one stream to another