You haven't said what programming environment you are using.
However progress bars are quite simple objects, the display a value in relation to it's minimum and maximum possible values. This is often used as a percentage by setting the minimum to 0 and the maximum to 100.
A progress bar only changes what it is displaying when it's display value is changed by the program so the program needs to be peforming an operation that is not atomic. That is an operation that does not only return once it is finished.
An examples of an atomic operation is copying a single file, the program calls CopyFile(Visual C++) and the function returns when it has completed the task, an example of a non-atomic operation is copying multiple files, the program calls CopyFile multiple times and has control returned to it at the end of each copy.
NOTE copying a single file can be made no-atomic by calling CopyFileEx rather than CopyFile.
What you want clearly falls into the second example I have given, to do this you need to
- Initialise your Progress Bar before the copy begins with it's minimum and maximum values. NOTE in C++ the default values for minimum and maximum are rather non-intuitively minimum=100, maximum=0
- Start your copy progress
- In between each file copy update the progress bar with the current progress
In a file copy situation the current progress can be represented either as the number files copied out of the number of files to copy or the amount of data copied out of the total amount of data to copy. The first of these is usually easier to calculate but does not give a very good represntation of the actual time it 1 of the files to copy is significantly larger than the others.