Sign in Join
FPDoc Onlineexperiment

TCustomMemoryStream.SaveToFile procedure

Member of TCustomMemoryStreampublicIn unit Classes

Writes the contents of the stream to a file.

Declaration

pascal
procedure SaveToFile(const FileName: string)

Description

SaveToFile writes the contents of the stream to a file with name FileName. It simply creates a filestream and writes the contents of the memorystream to this file stream using SaveToStream.

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

Stream:=TFileStream.Create(fmCreate,FileName);
  Seek(0,soFromBeginning);
  Stream.CopyFrom(Self,Size);

because the CopyFrom method copies the contents in blocks, while SaveToFile writes the contents of the memory as one big block.

Errors

If an error occurs when creating or writing to the file, an EStreamError exception may occur.

See also

An experiment, built from development snapshots. Not the official Free Pascal or Lazarus documentation.