Solved

Progressbar and file copy.

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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

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…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

707 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now