Copy file with a Progress bar
It sometimes interests to indicate the progress of copy of a file.
If we use a function of high level like CopyFile, we will simplify ourselves a lot the life, but we won't be able to use our ProgressBar...
The solution that I propose is the following one:
And repeat the process until you have read and save the complete file.
Notice: I have not put any confirmation of errors, that leaves it to you, you already know, test if the Source file exists, to give failure if there is not space in the disk to save the target file, or to check if the target file already exists.
The example uses a buffer of 2048 bytes. When bigger is the buffer more speed he will give you the routine.
Good, in fact, the good yield would have it if you equal the size from the buffer to the size of the clusters of the disk... (or multiples of it) but don't worry, neither it is so critical the gain of speed, whenever you don't lower the size of the buffer a lot.