protected void InvokeCopyProgress(CopyProgressEventArgs e) { if (CopyProgress != null) { CopyProgress(this, e); } }
/// <summary> /// The CopyProgressRoutine delegate is an application-defined callback function used with the CopyFileEx and MoveFileWithProgress functions. /// It is called when a portion of a copy or move operation is completed. /// </summary> /// <param name="TotalFileSize">Total size of the file, in bytes.</param> /// <param name="TotalBytesTransferred">Total number of bytes transferred from the source file to the destination file since the copy operation began.</param> /// <param name="StreamSize">Total size of the current file stream, in bytes.</param> /// <param name="StreamBytesTransferred">Total number of bytes in the current stream that have been transferred from the source file to the destination file since the copy operation began. </param> /// <param name="dwStreamNumber">Handle to the current stream. The first time CopyProgressRoutine is called, the stream number is 1.</param> /// <param name="dwCallbackReason">Reason that CopyProgressRoutine was called.</param> /// <param name="hSourceFile">Handle to the source file.</param> /// <param name="hDestinationFile">Handle to the destination file.</param> /// <param name="lpData">Argument passed to CopyProgressRoutine by the CopyFileEx or MoveFileWithProgress function.</param> /// <returns>A value indicating how to proceed with the copy operation.</returns> protected uint CopyProgressCallback( long TotalFileSize, long TotalBytesTransferred, long StreamSize, long StreamBytesTransferred, uint dwStreamNumber, uint dwCallbackReason, IntPtr hSourceFile, IntPtr hDestinationFile, IntPtr lpData) { switch (dwCallbackReason) { case CALLBACK_CHUNK_FINISHED: // Another part of the file was copied. CopyProgressEventArgs e = new CopyProgressEventArgs(TotalFileSize, TotalBytesTransferred); InvokeCopyProgress(e); return(e.Cancel ? PROGRESS_CANCEL : PROGRESS_CONTINUE); case CALLBACK_STREAM_SWITCH: // A new stream was created. We don't care about this one - just continue the move operation. return(PROGRESS_CONTINUE); default: return(PROGRESS_CONTINUE); } }
protected void InvokeCopyProgress( CopyProgressEventArgs e ) { if ( CopyProgress != null ) { CopyProgress( this, e ); } }
/// <summary> /// The CopyProgressRoutine delegate is an application-defined callback function used with the CopyFileEx and MoveFileWithProgress functions. /// It is called when a portion of a copy or move operation is completed. /// </summary> /// <param name="TotalFileSize">Total size of the file, in bytes.</param> /// <param name="TotalBytesTransferred">Total number of bytes transferred from the source file to the destination file since the copy operation began.</param> /// <param name="StreamSize">Total size of the current file stream, in bytes.</param> /// <param name="StreamBytesTransferred">Total number of bytes in the current stream that have been transferred from the source file to the destination file since the copy operation began. </param> /// <param name="dwStreamNumber">Handle to the current stream. The first time CopyProgressRoutine is called, the stream number is 1.</param> /// <param name="dwCallbackReason">Reason that CopyProgressRoutine was called.</param> /// <param name="hSourceFile">Handle to the source file.</param> /// <param name="hDestinationFile">Handle to the destination file.</param> /// <param name="lpData">Argument passed to CopyProgressRoutine by the CopyFileEx or MoveFileWithProgress function.</param> /// <returns>A value indicating how to proceed with the copy operation.</returns> protected uint CopyProgressCallback( long TotalFileSize, long TotalBytesTransferred, long StreamSize, long StreamBytesTransferred, uint dwStreamNumber, uint dwCallbackReason, IntPtr hSourceFile, IntPtr hDestinationFile, IntPtr lpData) { switch ( dwCallbackReason ) { case CALLBACK_CHUNK_FINISHED: // Another part of the file was copied. CopyProgressEventArgs e = new CopyProgressEventArgs( TotalFileSize, TotalBytesTransferred ); InvokeCopyProgress( e ); return e.Cancel ? PROGRESS_CANCEL : PROGRESS_CONTINUE; case CALLBACK_STREAM_SWITCH: // A new stream was created. We don't care about this one - just continue the move operation. return PROGRESS_CONTINUE; default: return PROGRESS_CONTINUE; } }