File Copy Progress
Posted on 2004-08-26
This is the deal, I have form that downloads a file from a remote server (this works 100% fine), but the file is fairly big so i have decided i would like to see the progress the file is making i want to have a ProgressBar Control on my form which shows the progress of the file copy (dir!), I fouind the code below but it was shockingly slow. there is only 1 file that has to copy.
Public Function CopyFileProgress3(sSrcFile As String, sDestFile As String, lTotalLen As Long, lBlock As Long)
'Form_CheckForUpdates.Caption = "Copying..."
Dim filetocopy As String: filetocopy = sSrcFile
Dim newfile As String: newfile = sDestFile
Open filetocopy For Binary As #1
Open newfile For Binary As #2
Dim flen As Long: flen = FileLen(filetocopy)
If flen = 0 Then
MsgBox "File is either empty or does not exist!"
Form_CheckForUpdates.ProgressBar.Min = 0
Form_CheckForUpdates.ProgressBar.Max = flen
Form_CheckForUpdates.ProgressBar.Value = 0
Dim c As Long: c = 0
Dim tmpchr As String * 1
Do While c < flen
Get #1, , tmpchr
Put #2, , tmpchr
c = c + 1
Form_CheckForUpdates.ProgressBar = c
Form_CheckForUpdates.Caption = "Finished"