To copy a file, never read/write a single byte, never use
. It's pointless and could make your code prohibitively slow, so measuring of the copy rate would be useless.
Open two files, one for read only, another for write only, in a cycle, read and write the content in big blocks
(take care about the size of the very last block, use actually read size). To calculate copy rate, time the points where each block is read and written and divide the size of block by time. You will need some mechanism to notify the user on the rate and progress, so you could use some callback function.