Recent

Author Topic: TmemoryStream...  (Read 209 times)

cdbc

  • Sr. Member
  • ****
  • Posts: 255
    • http://www.cdbc.dk
TmemoryStream...
« on: July 02, 2020, 12:05:59 pm »
Hi
Right, so i've got this form, collecting data from user and populates a business object. One of the members is a TMemoryStream, that loads a file, all fine and dandy, but what happens when the user cancel in the midst?!? In short, i need to get rid of the data already loaded in the memorystream. Would this be a viable solution:
Code: Pascal  [Select][+][-]
  1. procedure TfrmEditBlob.btnCancelClick(Sender: TObject);
  2. begin
  3.   TMemoryStream(fBlob.Blob).SetSize(0);              // delete blob contents
  4.   fBlob.Blob.Position:= 0;
  5.   Close; // just forget everything
  6. end;
TIA - Benny
If it ain't broke, don't fix it ;)

jamie

  • Hero Member
  • *****
  • Posts: 3538
Re: TmemoryStream...
« Reply #1 on: July 02, 2020, 12:14:23 pm »
Memorystream.Clear

that keeps it alive still but empties it ..
The only true wisdom is knowing you know nothing

 

TinyPortal © 2005-2018