unit MainFrm;interfaceuses
  Windows, Messages, SysUtils, Classes, Graphics, Controls,
  Forms, Dialogs, StdCtrls, ComCtrls, Gauges;type
  TMainForm = class(TForm)
    prbCopy: TProgressBar;
    btnCopy: TButton;
    procedure btnCopyClick(Sender: TObject);
  end;var
  MainForm: TMainForm;implementation{$R *.DFM}procedure TMainForm.btnCopyClick(Sender: TObject);
var
  SrcFile, DestFile: File;
  BytesRead, BytesWritten, TotalRead: Integer;
  Buffer: array[1..500] of byte;
  FSize: Integer;
begin
  { Assign both the source and destination files to their
    respective file variables }
  AssignFile(SrcFile, 'srcfile.tst');
  AssignFile(DestFile, 'destfile.tst');
  // Open the source file for read access.
  Reset(SrcFile, 1);                 //光标停在这里。说是数据没有定义
  try
   
    Rewrite(DestFile, 1);
    try
     
      try
       
        TotalRead := 0;
     
        FSize := FileSize(SrcFile);
        { Read SizeOf(Buffer) bytes from the source file
          and add these bytes to the destination file. Repeat this
          process until all bytes have been read from the source
          file. A progress bar is provided to show the progress of the
          copy operation. }
        repeat
          BlockRead(SrcFile, Buffer, SizeOf(Buffer), BytesRead);
          if BytesRead > 0 then
          begin
            BlockWrite(DestFile, Buffer, BytesRead, BytesWritten);
            if BytesRead <> BytesWritten then
              raise Exception.Create('Error copying file')
            else begin
              TotalRead := TotalRead + BytesRead;
              prbCopy.Position := Trunc(TotalRead / Fsize) * 100;
              prbCopy.Update;
            end;
          end
        until BytesRead = 0;
      except
        { On an exception, erase the destination file as it may be
          corrupt. Then re-raise the exception. }
        Erase(DestFile);
        raise;
      end;
    finally
      CloseFile(DestFile); // Close the destination file.
    end;
  finally
    CloseFile(SrcFile);   // Close the source file.
  end;
end;end.

解决方案 »

  1.   

    分不是money,但我只有最后65分。让我及个格,好吗。100天后,终一送分。小生我说到做到,不信搜一搜俺的
      

  2.   

    To  WGYKING(修罗是谁?!
    谢谢你的好意,你的大名在CSDN上也是如雷惯耳,谢谢。我希望你帮我解决一下。分全给你。谢谢非常感谢你这么关心,谢谢你的参与。唉.... 
      

  3.   

    上面的代码是delphi5开发人员指南的光盘。我用delphi7能打开,但就是运行时光标 Reset(SrcFile, 1);                 //光标停在这里。说是数据没有定义
      

  4.   

    To dext(德克斯特)谢谢你,这个文件是存在的.
     但出现以下错误
    file access denied
      

  5.   

    是不是你对这个文件没有访问权限
    比如,只读。
    还有,你为什么不用TFileStream