saving a records containing a member of type string to a file (Delphi, Windows)

后端 未结 5 1728
情书的邮戳
情书的邮戳 2020-12-22 06:13

I have a record that looks similar to:

type
  TNote = record
    Title : string;
    Note  : string;
    Index : integer;
  end;

Simple. Th

5条回答
  •  一个人的身影
    2020-12-22 07:14

    Why not write this out as XML? See my session "Practical XML with Delphi" on how to get started with this.

    Another possibility would be to make your records into classes descending form TComponent and store/retreive your data in DFM files.

    This Stackoverflow entry shows you how to do that.

    --jeroen

    PS: Sorry my XML answer was a bit dense; I'm actually on the road for two conferences (BASTA! and DelphiLive! Germany).

    Basically what you need to do is very simple: create a sample XML file, then start the Delphi XML Data Binding Wizard (available in Delphi since version 6).

    This wizard will generate a unit for you that has the interfaces and classes mapping XML to Delphi objects, and a few helper functions for reading them from file, creating a new object, etc. My session (see the first link above) actually contains most of the details for this process.

    The above link is a video demonstrating the usage of the Delphi XML Data Binding Wizard.

提交回复
热议问题