如何在Delphi中将动态数组保存到FileStream?

前端之家收集整理的这篇文章主要介绍了如何在Delphi中将动态数组保存到FileStream?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我在Delphi 2009中有以下结构:
type
  IndiReportIndi = record
    IndiName: string;
    NameNum: integer;
    ReportIndiName: string;
  end;

var
  XRefList: array of IndiReportIndi;

其中XRefList是动态数组.

我想将XRefList保存到FileStream.我该怎么做并包括所有IndiName和ReportIndiName字符串,以便在我稍后从该FileStream加载时它们都可以再次检索?

解决方法

使用: http://code.google.com/p/kblib/
type
  IndiReportIndi = record
    IndiName: string;
    NameNum: integer;
    ReportIndiName: string;
  end;

  TXRefList = array of IndiReportIndi;

var
  XRefList: TXRefList;

要将整个XRefList保存为流使用:

TKBDynamic.WriteTo(lStream,XRefList,TypeInfo(TXRefList));

要加载它:

TKBDynamic.ReadFrom(lStream,TypeInfo(TXRefList));
原文链接:https://www.f2er.com/delphi/102058.html

猜你在找的Delphi相关文章