|
-
Feb 28th, 2001, 10:21 AM
#1
Thread Starter
New Member
I am using the copyfile API to move large files (>1 Gb) on a network. The API works but due to network traffic and such, it can take from minutes to hours to complete.
I am wondering if there is a way of monitoring the copy process so that I can tell how far along the copy is ?
Thanks,
-
Aug 7th, 2004, 04:07 PM
#2
Hyperactive Member
Use CopyFileEx, but W9x/ME not supported.
AllApi sample:
VB Code:
'in a form (Form1)
Private Sub Form_Load()
'KPD-Team 2001
'URL: [url]http://www.allapi.net/[/url]
Dim Ret As Long
'set the graphics mode to persistent
Me.AutoRedraw = True
'print some text
Me.Print "Click the form to abort the filecopy"
'show the form
Me.Show
'start copying
Ret = CopyFileEx("c:\verybigfile.ext", "c:\copy.ext", AddressOf CopyProgressRoutine, ByVal 0&, bCancel, COPY_FILE_RESTARTABLE)
'show some text
Me.Print "Filecopy completed " + IIf(Ret = 0, "(ERROR/ABORTED)", "successfully")
End Sub
Private Sub Form_Click()
'cancel filecopy
bCancel = 1
End Sub
'in a module
Public Const PROGRESS_CANCEL = 1
Public Const PROGRESS_CONTINUE = 0
Public Const PROGRESS_QUIET = 3
Public Const PROGRESS_STOP = 2
Public Const COPY_FILE_FAIL_IF_EXISTS = &H1
Public Const COPY_FILE_RESTARTABLE = &H2
Public Declare Function CopyFileEx Lib "kernel32.dll" Alias "CopyFileExA" (ByVal lpExistingFileName As String, ByVal lpNewFileName As String, ByVal lpProgressRoutine As Long, lpData As Any, ByRef pbCancel As Long, ByVal dwCopyFlags As Long) As Long
Public bCancel As Long
Public Function CopyProgressRoutine(ByVal TotalFileSize As Currency, ByVal TotalBytesTransferred As Currency, ByVal StreamSize As Currency, ByVal StreamBytesTransferred As Currency, ByVal dwStreamNumber As Long, ByVal dwCallbackReason As Long, ByVal hSourceFile As Long, ByVal hDestinationFile As Long, ByVal lpData As Long) As Long
'adjust the caption
Form1.Caption = CStr(Int((TotalBytesTransferred * 10000) / (TotalFileSize * 10000) * 100)) + "% complete..."
'allow user input
DoEvents
'continue filecopy
CopyProgressRoutine = PROGRESS_CONTINUE
End Function
-
Aug 7th, 2004, 07:16 PM
#3
New Member
Please try SHFileOperation API.
-
Aug 7th, 2004, 11:44 PM
#4
Frenzied Member
Why do you people continue to respond to posts over 3 years old?!
Do you think it matters at this point
ice
:::`DISCLAIMER`:::
Do NOT take anything i have posted to be truthful in any way, shape or form.
Thank You!
--------------------------------
"Never heard about "hiking" poles. I usualy just grab a stick from the nature, and use that as a pole." - NoteMe
"Finaly I can look as gay as I want..." - NoteMe
Languages: VB6, BASIC, Java, C#. C++
-
Aug 8th, 2004, 04:59 AM
#5
Hyperactive Member
Yep, 
Of course I don't think Ray-TFR still waits for answer...
Though it can help users which have the same troubles today or later and are looking for the solution.
How do you think I've got to 3 years old thread?
PS: As you see, autodebug suggested using SHFileOperation, which works even under Win95, so I also have something new learned.
-
Aug 8th, 2004, 11:12 AM
#6
Frenzied Member
Well, if you want things users will be able to find you should probably post in the FAQS that is stickied. MAYBE people will look @ the faqs before they post a question or search the forums...
:::`DISCLAIMER`:::
Do NOT take anything i have posted to be truthful in any way, shape or form.
Thank You!
--------------------------------
"Never heard about "hiking" poles. I usualy just grab a stick from the nature, and use that as a pole." - NoteMe
"Finaly I can look as gay as I want..." - NoteMe
Languages: VB6, BASIC, Java, C#. C++
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
|