Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Progressbar and file copy.

Posted on 1998-10-03
2
Medium Priority
?
2,097 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 200 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

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…
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…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses

721 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