Converting TMemoryStream to 'String' in Delphi 2009

后端 未结 7 930
南方客
南方客 2020-11-28 05:52

We had the following code prior to Delphi 2009:

function MemoryStreamToString(M : TMemoryStream): String;
var
    NewCapacity: Longint;
begin
    if (M.Size          


        
7条回答
  •  醉梦人生
    2020-11-28 06:15

    There's a factor called TStringStream that will be able to assist you. . .you can load the contents of another flow like that:

    var StringStream: TStringStream; 
    begin StringStream := TStringStream.Create(''); 
    StringStream.CopyFrom(OtherStream, OtherStream.Size); 
    end;
    

    You can now get into the series for a String kind such as this: The data-string property comprises the series... but do not try so with large objects such as in the event that you load a huge file to some filestream then copy this to your own stringstream and make an effort to produce it cause it arranges a lot of memory!

    Hope that helps

提交回复
热议问题