Solved

Progressbar and file copy.

Posted on 1998-10-03
2
1,982 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
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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Path  to current project in Delphi. 2 92
Magic Software info 18 138
Multiple image collision 13 80
Delphi problems to abort a printjob 9 24
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
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…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

856 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