03-07-2003, 11:35 AM
I have to create a progress bar which shows the percentage of the file copying process. However, I don't know how to track the percentage (size transferred / total file size) of the file copying process. How to achieve this??
Thanks in advance!
03-07-2003, 11:41 AM
Use Binary access and read/write the data yourself. Then just calculate the percentage and display it. You might consider just using a picturebox for the progressbar, then you won't need any added dependencies. Or just use SHFileOperation API, which has a nice built-in progressbar.
03-07-2003, 11:51 AM
The file I need to copy is more than 500mb (a exe file)....I just don't know whether I can handle the copy process by my code. And also I don't want to display the built-in File copy dialog in WINDOWS. Could this be done??
03-07-2003, 11:55 AM
Yes, you can do it with VB code. Open the source file and read in 64K (or the amount left in the file). Then write the buffer to the destination. Paint the progressbar. Repeat until finished.
03-08-2003, 11:25 AM
I have use the get and put function....but...seems it seems very slow...
It takes more than 15 mins to copy a file with size less than 2mb....
Open SourcePath For Binary As #1
Open DestPath For Binary As #2
Get #1, , Buffer
Put #2, , Buffer
Anything wrong with my code???
03-08-2003, 11:28 AM
You're copying 1 byte at a time. Try copying larger chunks.
You could always use SHFileOperation to do the copying. It provides a nifty copying animation as it works. There are examples in this forum if you care to search.
03-08-2003, 12:43 PM
But I am still very confusing about how to track the percentage during the file copying operation........Is there any sample code ???
03-08-2003, 12:50 PM
lPercentageDone = (lBytesCopied / lTotalBytes) * 100
03-08-2003, 01:56 PM
I've got what I want. Thanks everyone!