If you receive that exception, and you are using something like:
Buffer: array [0..MAX_SIZE] of Char;
Than MAX_SIZE is too big, because Char can take small mount of data.
Use better something like this:
The following example opens a file of your choice and reads
the entire file into a dynamically allocated buffer. The
buffer and the size of the file are then passed to a routine
that processes the text, and finally the dynamically
allocated buffer is freed and the file is closed.
procedure TForm1.Button1Click(Sender: TObject);
if OpenDialog1.Execute then
Size := FileSize(F);
BlockRead(F, Buffer^, Size);
That code is taken from Delphi help, system.FreeMem function.