//翻出来的老程序,是保存文件到xml,原来学习时试做的,效率不高,给你借鉴一下吧
function TForm1.LoadDataFromFile(FileName: string;var FileLen : Integer) : string;
var
F : File of Byte;
bBlock : Byte;
FLen : Integer;
I : Integer;
begin
AssignFile(F,FileName);
Reset(F);
FLen := FileSize(F);
Result := '';
for I := 0 to FLen-1 do
begin
Read(F,bBlock);
Result := Result+IntToHex(bBlock,2);
end;
CloseFile(F);
FileLen := FLen;
end;
procedure TForm1.SaveDataToFile(vNodeValue: string;
FileName: string;FileLen : Integer);
var
F : File of Char;
bBlock : Char;
I : Integer;
sBlock : string;
P : PChar;
begin
AssignFile(F,FileName);
ReWrite(F);
P := AllocMem(1);
for I := 0 to FileLen-1 do
begin
sBlock := vNodeValue[I*2+1]+vNodeValue[I*2+2];
sBlock := LowerCase(sBlock);
HexToBin(PChar(sBlock),P,1);
bBlock := P^;
Write(F,bBlock);
end;
CloseFile(F);
end;