RAD Studio VCL Reference
ContentsIndex
PreviousUpNext
TMemoryStream.LoadFromFile Method

Loads the entire contents of a file into the memory buffer.

Pascal
procedure LoadFromFile(const FileName: string);
C++
__fastcall LoadFromFile(const AnsiString FileName);

Use LoadFromFile to fill the memory stream with the contents of a file. Pass the name of the file as the FileName parameter. LoadFromFile allows an application to read the contents of a file into the memory stream without having to explicitly create and free a file stream object. 

LoadFromFile reallocates the memory buffer so that the contents of the file will exactly fit. It sets the Size property accordingly, and then reads the entire contents of the file into the memory buffer. Thus, LoadFromFile will discard any pre-existing data stored in the memory stream. 

 

Copyright(C) 2008 CodeGear(TM). All Rights Reserved.
What do you think about this topic? Send feedback!