ProgressBar with copyfile

Posted on 1998-12-12
Medium Priority
Last Modified: 2008-03-10
I want to use a progressbar with the copyfile function.
I want to let users know the progress of copying a file.
How would I do this?
Question by:waipahu
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
  • 2
  • 2
  • +1
LVL 12

Expert Comment

ID: 1350780
You would be better to use SHFileOperation - this has support for the progress bar display all built in.

LVL 20

Expert Comment

ID: 1350781
Raymond is right. But if you need it for winNT only, you can use the API CopyFileEx. It's a little bit easier than the SHFileOperation, I think.

Regards... Madshi.

Author Comment

ID: 1350782
What is SHFIleOperation? Sorry, new to delphi.
Can you give me a sample code?
Do you  mean i have to do a readblock and writeblock????
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!

LVL 20

Expert Comment

ID: 1350783
SHFileOperation is win32API. You'll find the documention in the win32.hlp file. Just write SHFileOperation into your editor and press F1.

Regards... Madshi.

Accepted Solution

venks earned 30 total points
ID: 1350784
Dear waipahu
Look at the help file of TFileOperation Component Version 1 which encapsulates SHfileoperation of win32 API.You can downlaod the component from

URL: http://www.chez.com/herveroz 

Help file of the component
| TFileOperation Component Version 1.0                                         |
| Author: Hervé Roz                                                            |
| e-mail: hroz@chez.com                                                        |
| Description:                                                                 |
|   This component encapsulates the ShFileOperation API of Microsoft Windows.  |
| Performs a copy, move, rename, or delete operation on a file system object.  |
| Properties:                                                                  |
|   Source: String that contains the names of the source files, wildcard       |
|           filename (*.*) is accepted.                                        |
|           You can include several mask separeted by a ';'.                   |                                       |
|   Destination: String that specifies the destination for the moved, copied,  |
|                 or renamed file.                                             |
|   Mode:                                                                      |
|    -foCopy      Copies the files specified by pFrom to the location            |
|               specified by pTo.                                              |
|    -foDelete      Deletes the files specified by pFrom (pTo is ignored).         |
|    -foMove      Moves the files specified by pFrom to the location             |
|               specified by pTo.                                              |
|    -foRename      Renames the files specified by pFrom.                          |
|   Options:                                                                   |
|    -fofAllowUndo         Preserves undo information, if possible.            |
|    -fofConfirmMouse         Not implemented.                                    |
|    -fofFilesOnly         Performs the operation only on files if a wildcard  |
|                          filename (*.*) is specified.                        |
|    -fofMultiDestFiles    Indicates that the pTo member specifies multiple    |
|                          destination files (one for each source file) rather |
|                          than one directory where all source files are       |
|                          to be deposited.                                    |
|    -fofNoConfirmation    Responds with "yes to all" for any dialog box that  |
|                          is displayed.                                       |
|    -fofNoConfirmMkDir    Does not confirm the creation of a new directory    |
|                          if the operation requires one to be created.        |
|    -fofRenameOnCollision Gives the file being operated on a new name         |
|                          (such as "Copy #1 of...") in a move, copy,          |
|                          or rename operation if a file of the target name    |
|                          already exists.                                     |
|    -fofSilent            Does not display a progress dialog box.             |
|    -fofSimpleProgress    Displays a progress dialog box, but does not show   |
|                          the filenames.                                      |
|    -fofWantMappingHandle Not implemented.                                    |
|   Title: String to use as the title for a progress dialog box.               |
|          This member is used only if Options includes fofSimpleProgress.     |
|   AbortByUser: Value that receives True if the user aborted any file         |
|                operations before they were completed or FALSE otherwise.     |
|                                                                              |
| (*): Read only property                                                      |
| Methods:                                                                     |
|   function Execute: Performs the copy, move, rename, or delete operation.    |
|     Returns zero if successful or nonzero value if an error occurs.          |
| Events:                                                                      |

| Installation                                                                 |
| 1. Unzip the file to any directory you like, for instance                    |
|   C:\Delphi 3\Source\FileOper, ...                                           |
| 2. Start Delphi and close any projects and/or files                          |
| 3. From the menu, choose 'Components/Install Components...'                  |
| 4. In the dialog, click 'Browse'                                             |
| 5. Navigate to your chosen directory and select 'FileOper.pas'               |
| 6. Click OK the way back                                                     |
| 7. In the dialog you have now set the unit file                              |
| 8. Click OK to perform the install                                           |

| ******************************* IMPORTANT ********************************** |
|     This software is absolutely free. Use it and enjoy Delphi.               |
|     All I want is to know why and how you are using this                     |
|     software.                                                                |
|                                                                              |
|     Suggestions for improvement and fixes are always welcome,                |
|     although no guarantee is made when we'll implemement them.               |
|                                                                              |
|     If you do use this component, please drop me an email                    |
|     telling me how you used it.                                              |
|                                                                              |
|     For bug reports, suggestions, new versions etc. contact me:              |
|                                                                              |
|     e-mail: hroz@chez.com                                                    |
|     URL: http://www.chez.com/herveroz                                        |
|                                                                              |


Expert Comment

ID: 1350785
Dear waipahu
Either accept the answer or reject it.But do something

Author Comment

ID: 1350786
Sorry, been busy...
I'll try your recommendation...
Thanks again!


Featured Post

[Webinar] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

Question has a verified solution.

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

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 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…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses

762 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