Delphi实现类的持久化保存(DFM格式)

var inStream,outStream:TMemoryStream;
begin
   inStream:=TMemoryStream.Create;
   outStream:=TMemoryStream.Create;
   try
      inStream.WriteComponent(self);
      inStream.Position:=0;
      ObjectBinaryToText(inStream,outStream);
      outStream.Position:=0;
      outStream.SaveToFile('c.txt');
   finally
     FreeAndNil(inStream);
     FreeAndNil(outStream);
   end;
   //WriteComponentResFile('c.res',self);
end;

读取,反过来就是了,不多说。

posted on 2019-06-08 22:45  癫狂编程  阅读(499)  评论(0编辑  收藏  举报

导航

好的代码像粥一样,都是用时间熬出来的