Solved

Progressbar and file copy.

Posted on 1998-10-03
2
2,028 Views
Last Modified: 2012-05-04
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
Comment
Question by:Vincentg
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 20

Expert Comment

by:Madshi
ID: 1341653
Vincent,

look at the win API "CopyFileEx".

Regards, Madshi.
0
 
LVL 7

Accepted Solution

by:
Motaz earned 50 total points
ID: 1341654
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…

691 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question