本文介绍了如何将动态数组保存到Delphi中的FileStream?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在Delphi 2009中有以下结构: 键入
IndiReportIndi = record
IndiName:串;
NameNum:integer;
ReportIndiName:string;
结束
var
XRefList:IndiReportIndi的数组;
其中XRefList是一个动态数组。
我想保存XRefList到FileStream。我该怎么做,并且包括所有的IndiName和ReportIndiName字符串,以便当我稍后从该FileStream加载时,它们都将被再次检索。
解决方案
使用:
type
IndiReportIndi = record
IndiName:string;
NameNum:integer;
ReportIndiName:string;
结束
TXRefList = IndiReportIndi的数组;
var
XRefList:TXRefList;
将整个XRefList保存为流使用:
TKBDynamic.WriteTo(lStream,XRefList,TypeInfo(TXRefList));
要加载它:
TKBDynamic.ReadFrom(lStream,XRefList,TypeInfo(TXRefList));
I have the following structures in Delphi 2009:
type
IndiReportIndi = record
IndiName: string;
NameNum: integer;
ReportIndiName: string;
end;
var
XRefList: array of IndiReportIndi;
where XRefList is a dynamic array.
I want to save XRefList to a FileStream. How do I do that AND include all the IndiName and ReportIndiName strings so that they will all be retrievable again when I later load from that FileStream?
解决方案
Use: http://code.google.com/p/kblib/
type
IndiReportIndi = record
IndiName: string;
NameNum: integer;
ReportIndiName: string;
end;
TXRefList = array of IndiReportIndi;
var
XRefList: TXRefList;
To save whole XRefList to stream use:
TKBDynamic.WriteTo(lStream, XRefList, TypeInfo(TXRefList));
To load it back:
TKBDynamic.ReadFrom(lStream, XRefList, TypeInfo(TXRefList));
这篇关于如何将动态数组保存到Delphi中的FileStream?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!