总结


procedure TForm1.Button7Click(Sender: TObject);
var
  FromF, ToF: file;
  NumRead, NumWritten: dWord;
  Buf: array[1..2048] of Char;
  countbuf: array of Char;
  FromFile, ToFile: string;
  i: integer;
  one, two: integer;
begin
 //5750211
  FromFile := 'c:\222.rar';
  ToFile := 'c:\777.rar';
  setlength(countbuf, 5750211);
  one := 5750211 div 2048;
  two := 5750211 mod 2048;
  i := 0;
  //读buff
  AssignFile(FromF, FromFile);
  Reset(FromF, 1);
  AssignFile(ToF, ToFile);
  Rewrite(ToF, 1);
 
  repeat
    BlockRead(FromF, Buf, SizeOf(Buf), NumRead);
    if NumRead = 2048 then
    begin
      Move(Buf, countbuf[2048 * i], NumRead);
      i := i + 1;
    end
    else
    begin
      Move(Buf, countbuf[2048 * one], NumRead);
    end;
  until (NumRead = 0);

  //通过buff写文件
  for i := 0 to one - 1 do
  begin
    Move(countbuf[i * 2048], Buf, 2048);
    BlockWrite(ToF, Buf, 2048, NumWritten);
  end;
  Move(countbuf[one * 2048], Buf, two);
  BlockWrite(ToF, Buf, two, NumWritten);
 
  CloseFile(FromF);
  CloseFile(ToF);
end;

本文出自 “601880” 博客,谢绝转载!

你可能感兴趣的:(职场,休闲)