Copy file and rename
Put
a ProgressBar in your form . Put a TButton and put this code in their OnClick
event:
Procedure TForm1.Button1Click ( Sender : TObject ) ;
Var
Source ,
Destination : File Of byte ;
Buffer : Array[
0..4096 ] Of char ;
Step :
integer ;
Percent : longint ;
Begin
AssignFile (
Source , 'c:\my documents\Application.exe' ) ;
reset (
Source ) ;
AssignFile (
Destination , 'c:\Program.exe' ) ;
rewrite (
Destination ) ;
Percent :=
FileSize ( Source ) ;
ProgressBar1.Max := Percent ;
ProgressBar1.Min := 0 ;
While
Percent > 0 Do
Begin
BlockRead ( Source , Buffer[ 0 ] , SizeOf ( Buffer ) , Step ) ;
Percent := Percent - Step ;
BlockWrite ( Destination , Buffer[ 0 ] , Step ) ;
ProgressBar1.Position := ProgressBar1.Position + Step ;
End ;
CloseFile (
Source ) ;
CloseFile (
Destination ) ;
End ;