You're doing much more than you have to in order to accomplish the conversion. With the presumption that MyBinaryFile.dat
is actually a binary format Delphi TClientDataSet
file, these two lines of code (with no additional setup) will work:
ClientDataSet1.LoadFromFile('D:\Temp\MyBinaryFile.dat');
ClientDataSet1.SaveToFile('D:\Temp\MyXMLFile.xml', dfXMLUTF8);
Without knowing more about what your MyBinaryFile.dat
is, and no information about the errors you're getting, it's pretty difficult to provide more information. Tested and working with the standard animals.cds
in Delphi 7 (from C:\Program Files\Common Files\Borland Shared\Data
in a standard D7 install on a Windowx XP virtual machine).
It seems, from your comment below, that the actual problem you're having is a compiler error about an unidentified identifier TClientDataSet
when you try and create it in code. If you have a high enough SKU for Delphi 7 that includes TClientDataSet
(IIRC, Professional and higher), you can just add DBClient
to your uses clause:
implementation
uses
DBClient;
procedure TForm1.FormShow(Sender: TObject);
var
CDS: TClientDataSet;
begin
CDS := TClientDataSet.Create(nil);
try
CDS.LoadFromFile('MyBinaryFile.dat');
CDS.SaveToFile('MyXMLFile.xml', dfXMLUTF8);
finally
CDS.Free;
end;
end;
Or, better yet, if you're creating a VCL Forms application, just drop a TClientDataSet
on your form; you'll find it on the DataAccess
tab in the component palette.