Ключевыми являются вызовы Read/WriteListBegin и Read/WriteListEnd. Без них вы получите исключение.
procedure TForm1.Button1Click(Sender: TObject); var sWrite,sRead : string[25]; MyStream : TMemoryStream;MyWriter : TWriter;MyReader : TReader;begin MyStream := TMemoryStream.Create;MyStream.SetSize(4096);MyWriter := TWriter.Create(MyStream,4096);sWrite := 'sWriteContents'; MyWriter.WriteListBegin;MyWriter.WriteString(sWrite);MyWriter.WriteListEnd;MyWriter.free; MyStream.Seek(0,0); MyReader := TReader.Create(MyStream,4096);MyReader.ReadListBegin;sRead := MyReader.ReadString;MyReader.ReadListEnd;MyReader.free; Label1.Caption := sRead;MyStream.free;end; |
[000645]