コード例 #1
0
ファイル: PInvokeFileMoveX.cs プロジェクト: dave-q/FileMover
        /// <summary>
        /// A function that can be used as CopyProgressRoutine delegate and is passed into the win32 method
        /// </summary>
        /// <param name="TotalFileSize"></param>
        /// <param name="TotalBytesTransferred"></param>
        /// <param name="StreamSize"></param>
        /// <param name="StreamBytesTransferred"></param>
        /// <param name="notUsed"></param>
        /// <param name="CallbackReason"></param>
        /// <param name="sourceFileHandle"></param>
        /// <param name="destinationFileHandle"></param>
        /// <param name="notUsed2"></param>
        /// <returns></returns>
        private CopyProgressResult CopyProgressFunc(
            long TotalFileSize,
            long TotalBytesTransferred,
            long StreamSize,
            long StreamBytesTransferred,
            uint notUsed,
            CopyProgressCallbackReason CallbackReason,
            IntPtr sourceFileHandle,
            IntPtr destinationFileHandle,
            IntPtr notUsed2
            )
        {
            var streamSize       = StreamSize;
            var streamBytesTrans = StreamBytesTransferred;

            _totalFileSize = TotalFileSize;
            var progressResult = CopyProgressResult.PROGRESS_CONTINUE;

            if (CallbackReason == CopyProgressCallbackReason.CALLBACK_CHUNK_FINISHED)
            {
                var fileMoveEventArgs = new FileMoveProgressArgs(TotalFileSize, TotalBytesTransferred);
                ProgressCallback(fileMoveEventArgs);

                if (fileMoveEventArgs.Cancelled)
                {
                    progressResult = CopyProgressResult.PROGRESS_CANCEL;
                }
            }
            return(progressResult);
        }
コード例 #2
0
ファイル: PInvokeFileMoveX.cs プロジェクト: dave-q/FileMover
        /// <summary>
        /// Handles the the returned boolean of the win32 method, along with the processing of the LastWin32 error if it failed
        /// </summary>
        /// <param name="sourcePath"></param>
        /// <param name="sucessDescriptor"></param>
        private void HandleResult(string sourcePath, SuccessDescriptor sucessDescriptor)
        {
            FileMoveProgressArgs moveEventArgs;

            if (!sucessDescriptor.IsSuccess)
            {
                moveEventArgs = HandleFailed(sucessDescriptor, _totalFileSize);
            }
            else
            {
                //doing this as small files, never get called back from the Win32 method and hence the progress is never updated, so this is make sure 100% is returned once it is complete
                moveEventArgs = new FileMoveProgressArgs(_totalFileSize, _totalFileSize);
            }
            ProgressCallback(moveEventArgs);
        }
コード例 #3
0
ファイル: InternalFileMover.cs プロジェクト: dave-q/FileMover
 internal void ProgressCallback(FileMoveProgressArgs fileMoveEventArgs)
 {
     _progressUpdater(fileMoveEventArgs);
 }