Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2148
  • Last Modified:

Progressbar and file copy.

Can someone tell me how to use the progressbar
when copying a file to disk.
I use the copyfile option of delphi.

Thanks,
Vincent
0
Vincentg
Asked:
Vincentg
1 Solution
 
MadshiCommented:
Vincent,

look at the win API "CopyFileEx".

Regards, Madshi.
0
 
MotazCommented:
You must write your own copy.. It's very easy :

procedure FileCopy(SourceName,DestName:string);
var
  SourceF,DestF:file;
  Buf:array [0..1023] of byte;
  NumRead,FSize,BytesCopied:integer;
begin
  AssignFile(SourceF,SourceName);
  AssignFile(DestF,DestName);
  FileMode:=0;
  Reset(SourceF,1);
  Rewite(DestF,1);
  FSize:=FileSize(SourceF);
  BytesCopied:=0;
  while not Eof(SourceF) do
  begin
    Blockread(SourceF,Buf,SizeOf(Buf),NumRead);
    Blockwrite(DestF,Buf,NumRead);
    Inc(BytesCopied,NumRead);
    ProgressBar1.Position:=(BytesCopied*100) div FSize;
    Application.ProcessMessages;
  end; (* while *)
  CloseFile(SourceF);
  CloseFile(DestF);
end;

Motaz from Sudan.
motaz1@yahoo.com
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now