哪位朋友有关于记录文件操作的详细Demo,就是关于插入、读取、删除(文件指针)
或者是有  《编程经典Delphi》24讲   这个教程的配置代码也可以,这里面也有讲记录文件,但是讲的不算详细,要看配置代码才可以理解得比较快,谢谢了
[email protected]

解决方案 »

  1.   

    可以参见下面的博客:
    http://www.cnblogs.com/del/category/115742.html
      

  2.   

    那里没看到要找的东西
    我是这样写滴,不过在插入记录到文件中的时候就出错
    谁帮忙看一下,怎么修
    unit Unit1;interfaceuses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, StdCtrls;
    type
      TMyRecord = record
        Mname:string[8];
        Mcompany:string[40];
        MAddRess:string[40];
        MPhoneNum:String[15];
        Msex:string[4];
    end;type
      TForm1 = class(TForm)
        Edit1: TEdit;
        Edit2: TEdit;
        Edit3: TEdit;
        Edit4: TEdit;
        Label1: TLabel;
        Label2: TLabel;
        Label3: TLabel;
        Label4: TLabel;
        Button1: TButton;
        Button2: TButton;
        Button3: TButton;
        Button4: TButton;
        Button5: TButton;
        Button6: TButton;
        Button7: TButton;
        Button8: TButton;
        Button9: TButton;
        Button10: TButton;
        Edit5: TEdit;
        Label5: TLabel;
        procedure FormCreate(Sender: TObject);
        procedure Button5Click(Sender: TObject);
      private
        { Private declarations }
      public
        { Public declarations }
      end;
    const
      FileName='MyRecordFile.wmk'; //定义常量var
      Form1: TForm1;
      MyFile:file of TMyRecord;
      MyRecord:TMyRecord;
    implementation{$R *.dfm}procedure TForm1.FormCreate(Sender: TObject);
    begin
      if not FileExists(Filename) then
        begin
          AssignFile(MyFile,FileName);  //关联
          try
            Rewrite(MyFile);    //创建,并使之打开
          except   
            MessageDlg('不能创建指定的文件',mtError,[mbOK],0);
            close;
          end;
        end
      else                              //如果文件已存在
        begin
          AssignFile(MyFile,FileName); 
          Reset(MyFile);               //打开记录文件
          if FileSize(MyFile) > 0 then //如果指定的文件不为空, 返回记录文件中记录的条数
          begin
            Seek(MyFile,0);            //文件指针
            read(MyFile,MyRecord);    
            Edit1.Text := MyRecord.Mname;
            Edit2.Text := MyRecord.Mcompany;
            Edit3.Text := MyRecord.MAddRess;
            Edit4.Text := MyRecord.MPhoneNum;
            Edit5.Text := MyRecord.Msex;
          end;
        end;
    end;
    procedure TForm1.Button5Click(Sender: TObject);
    var
      i,TempPos:Integer;
    begin
      TempPos := FilePos(MyFile);   //当前文件指针位置
      if Edit1.Text = '' then Exit; 
      if FileSize(MyFile) > 0 then  
       begin
        for i:=0 to FileSize(MyFile)-1 do
          begin
            Seek(MyFile,i);
            Read(MyFile,MyRecord);
            if MyRecord.Mname <> Edit1.Text then
              Continue
            else
              Seek(MyFile,TempPos);
            if FileSize(MyFile) = FilePos(MyFile) then  //如果指针是在最后一条记录的话
              begin
                MyRecord.Mname := Edit1.Text;
                MyRecord.Mcompany := Edit2.Text;
                MyRecord.MAddRess := Edit3.Text;
                MyRecord.MPhoneNum := Edit4.Text;
                MyRecord.Msex := Edit5.Text;
                Reset(MyFile);
                Seek(MyFile,FileSize(MyFile));
                Write(MyFile,MyRecord);
              end;
          end;
       end
      else
       begin
         for i:=FileSize(MyFile) downto Filesize(MyFile) do
           begin
             //将文件指针所指的记录都向后移动一个位置
             Seek(MyFile,i-1);
             read(MyFile,MyRecord);
             Seek(MyFile,i);
             write(MyFile,MyRecord);
           end;
           MyRecord.Mname := Edit1.Text;
           MyRecord.Mcompany := Edit2.Text;
           MyRecord.MAddRess := Edit3.Text;
           MyRecord.MPhoneNum := Edit4.Text;
           MyRecord.Msex := Edit5.Text;
           Seek(MyFile,Filepos(MyFile)-1);
           Write(MyFile,MyRecord);
       end;
    end;end.
      

  3.   

    我看错了,才50分呀,不帮了,若给100分,我就帮你
    更新说明
    1)数据库student.bin内容加密;
    2)定义 TStudent 结构的指针类型 TPRec;
    3)窗体默认大小,窗体调整不能少于默认大小;
    4)list index out of bounds(-1) 错误问题
    5)数据库已“加密”处理
      

  4.   

    我编译好的DELPHI程序,上传到这里
    http://download.csdn.net/source/3287846
    文件名为:小型数据库基本操作实例DEMO
      

  5.   

    你呀,太伤人心了呀
     
    “记录文件的插入、读取、删除[问题点数:50分,
    无满意答案结帖,结帖人:xunlei12343]”     
    我们都白白劳动了呀