unit
Unit2;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ComCtrls;
type
TForm2 =
class
(TForm)
Animate1: TAnimate;
ProgressBar1: TProgressBar;
procedure
FormShow(Sender: TObject);
procedure
Animate1Close(Sender: TObject);
private
public
procedure
Copy( copyFrom, copyTo:
string
);
end
;
var
Form2: TForm2;
implementation
{$R *.dfm}
procedure
TForm2
.
Copy(copyFrom, copyTo:
string
);
const
BufSize =
3
*
4
*
4096
;
type
PBuffer = ^TBuffer;
TBuffer =
array
[
1..
BufSize]
of
Byte
;
var
f1, f2:
file
;
Size, SizeDone:
integer
;
Buffer: TBuffer;
begin
AssignFile( f1, copyFrom );
AssignFile( f2, copyTo );
Reset( f1,
1
);
Rewrite( f2,
1
);
Size := FileSize( f1 );
ProgressBar1
.
Max := Size;
Animate1
.
Active :=
true
;
repeat
BlockRead( f1, Buffer, BufSize, Size );
Inc( SizeDone, Size );
ProgressBar1
.
Position := SizeDone;
BlockWrite( f2, Buffer, Size );
Application
.
ProcessMessages;
until
Size < BufSize;
Animate1
.
Active :=
false
;
Self
.
Close;
end
;