This is not a solution... but... I screwed around for about two hours with
this, and got almost there. Unfortunately, I don't have any more time
tonight. Create this code as a class. The only problem with it is that I
can't pass the AddressOf the the UpdateProgress routine to the API function.
I am really not up to speed yet on .NET - I'm sure it can be done, I just
don't know how. I'll try to look at it this weekend.
Public Declare Function CopyFileEx Lib "kernel32" Alias "CopyFileExA"
(ByVal lpExistingFileName As String, ByVal lpNewFileName As String, ByVal
lpProgressRoutine As Long, ByVal lpData As Long, ByVal pbCancel As Long,
ByVal dwCopyFlags As Long) As Long
Private Const COPY_FILE_RESTARTABLE As Long = &H2
Private Const PROGRESS_CONTINUE As Long = 0
Private Const PROGRESS_CANCEL As Long = 1
Private Const PROGRESS_STOP As Long = 2
Private Const PROGRESS_QUIET As Long = 3
Public Event Progress(ByVal TotalFileSize As Object, ByVal
TotalBytesTransferred As Object, ByVal Cancel As Boolean)
Public Sub CopyFile(ByVal SourceFile As String, ByVal DestFile As
String)
CopyFileEx(SourceFile, DestFile, AddressOf UpdateProgress, 0, False,
COPY_FILE_RESTARTABLE)
End Sub
Private Function UpdateProgress(ByVal TotalFileSize As Object, ByVal
TotalBytesTransferred As Object, ByVal StreamSize As Object, ByVal
StreamBytesTransferred As Object, ByVal dwStreamNumber As Long, ByVal
dwCallbackReason As Long, ByVal hSourceFile As Integer, ByVal
hDestinationFile As Integer, ByVal lpData As Integer) As Integer
Dim blnCancel As Boolean
RaiseEvent Progress(TotalFileSize, TotalBytesTransferred, blnCancel)
If blnCancel = True Then
Return PROGRESS_CANCEL
Else
Return PROGRESS_CONTINUE
End If
End Function
"hz****@nopost.com" <hz*************@discussions.microsoft.com> wrote in
message news:59**********************************@microsof t.com...
Usig VB .NET 2003, I'm writing a simple app that copies 1 or more files.
Requiremtns state that I need two progress bars one for current file copy
progress and one for overall progress.
My problem is that I'm not sure how to obtain progress about a file as it
is
being copied. I've read some thread about using the SHFileOperation API
but
I'm lost as to how to implemt that in .NET.
Can someone give me a pointer to some doco? Also an example of the
implemtation and usage of the API wouild be appreciated