type tperson=record
   name:string[20];
   sex:string[10];
end;
var fl:file of tperson;
var p:tperson
procedure button1click()
begin
  assignfile(fl,'c:\1.txt');
  reset(fl);
  p.name:='xueglsoft';
  p.sex:='mail';
  seek(fl,filesize(fl));//locate the end of file
  write(fl,p);
end;

解决方案 »

  1.   

    type 
      TData = record
        Name : array[0..20]of Char;
        job  : array[0..20]of Char;
      end;var
      aData : TData;
      Handle: Integer;
    begin
      with aData do
      begin
        Name := 'Happyboy';
        job  := 'Programming';
      end;
      Handle:=FileCreate('C:\a.xxx');
      if Handle <> 0 then
      begin
        FileSeek(Handle,0,2);  //指针移到文件尾
        FileWrite(Handle,aData,Sizeof(TData));  //写入aData
      end;
      FileClose(Handle);
    end;
      

  2.   

    Seek(F,FileSize(F));
    Write(F,...);