Date: Sun, 08 Jun 2003 06:31:37 -0500 From: Chris Willig Newsgroups: borland.public.delphi.language.objectpascal Subject: Re: MemoryStream Stijn Verrept wrote: > How can I load 10MB of a file into MemoryStream and later the next 10MB? > MemoryStream.LoadFromFile loads the complete file into memory. > > > Thanks in advance, > > Stijn Verrept. var FS : TFileStream; MS : TMemoryStream; begin FS := TFileStream.Create({AFilename}, fmOpenRead or fmShareDenyWrite); try FS.Seek(0, soFromBeginning); MS := TMemoryStream.Create; try while MS.CopyFrom(FS, {10MB}) > 0 do begin MS.Seek(0, soFromBeginning); ... MS.Size := 0; end; finally MS.Free; end; finally FS.Free; end; end;