|
-
Jul 19th, 2000, 12:20 PM
#1
Thread Starter
Addicted Member
Hello!
Does anyone know how to copy a file with progress indicator (percent, bytes complete...)?
Zvonko
Zvonko Bostjancic
Ilirska Bistrica, Slovenia
[email protected]
Using VS6 Professional with SP3
Programming mostly in VB and I've started to learn VC++ & MFC
-
Jul 19th, 2000, 12:54 PM
#2
Frenzied Member
sure...
Sure you can.
progressBar.Max = FileLen(MYFILE)
MYCHUNK = 500
Take chunks of a file, say 500 Bytes at a time, Set the ProgressBar.Value = ProgressBar.Value + MYCHUNK
and then write that chunk to antoher file
Put it in a loop and you're ready.
If you want the code just reply, I'm in hurry

Jop - validweb.nl
Alcohol doesn't solve any problems, but then again, neither does milk.
-
Jul 19th, 2000, 01:08 PM
#3
Try this. Make a Form with a CommandButton, CommonDialog, Label and ProgressBar and put the following code into the Form.
Code:
Private Sub Command1_Click()
Dim Source As String
Dim Dest As String
Dim Data As String
Dim TransferRate As Integer
CommonDialog1.CancelError = True
CommonDialog1.Filter = "All Files|*.*"
CommonDialog1.ShowOpen
If Err <> 32755 Then
Source = CommonDialog1.filename
Dest = Source & " - Copy 2"
Open Source For Binary As #1
Open Dest For Binary As #2
ProgressBar1.Max = FileLen(Source)
TransferRate = 1024
Do Until LOF(1) = Loc(1) Or EOF(1)
Data = ""
If LOF(1) - Loc(1) < ChunkSize Then
Data = String(LOF(1) - Loc(1), 0)
Else
Data = String(ChunkSize, 0)
End If
Get #1, , Data
Put #2, , Data
Label1.Caption = Loc(1) & " bytes out of " & LOF(1) & " transfered"
If ProgressBar1.Value + TransferRate > FileLen(Source) Then Exit Do
ProgressBar1.Value = ProgressBar1.Value + TransferRate
Loop
End If
End Sub
you will be asked to search for the file in the CommonDialog. When you find it, it will copy it as yourfilename - Copy2. When it's copying, it will show the status with a Label and the ProgressBar.
-
Jul 19th, 2000, 05:14 PM
#4
Thread Starter
Addicted Member
Thanks, guys!
You're sooooo gooood!!!
I don't know what would I do without you... 
Zvonko Bostjancic
Ilirska Bistrica, Slovenia
[email protected]
Using VS6 Professional with SP3
Programming mostly in VB and I've started to learn VC++ & MFC
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|