Example #1
0
        /// <summary>
        /// Callback handler from Directory.Copy/Move operations.
        /// </summary>
        /// <returns>Returns 'Continue' to localized error handling (in the source caller).</returns>
        CopyMoveProgressResult CopyMoveProgressHandler(long totalFileSize, long totalBytesTransferred,
                                                       long streamSize, long streamBytesTransferred, int streamNumber,
                                                       CopyMoveProgressCallbackReason callbackReason, object userData)
        {
            if (userData != null)
            {
                string[] files = userData.ToString().Split('|');
                OnProgress("CopyMoveProgress",
                           string.Format("Copied file: {0}  [to]  {1}", files[0], files[1]),
                           StatusType.Running, _startInfo.InstanceId, _cheapSequence++, false, null);
            }

            return(CopyMoveProgressResult.Continue);
        }
Example #2
0
        private CopyMoveProgressResult CopyProgressCallback(long totalFileSize, long totalBytesTransferred, long StreamSize, long StreamBytesTransferred, int StreamNumber, CopyMoveProgressCallbackReason CallbackReason, Object UserData)
        {
            double pct = totalBytesTransferred * 100.0 / totalFileSize;

            this.PercentDone = pct > 100.0 ? 100.0 : pct;
            return(CopyMoveProgressResult.Continue);
        }
Example #3
0
        private static CopyMoveProgressResult ProgressHandler(long totalFileSize, long totalBytesTransferred, long streamSize, long streamBytesTransferred, int streamNumber, CopyMoveProgressCallbackReason callbackReason, object userData)
        {
            if (callbackReason == CopyMoveProgressCallbackReason.StreamSwitch)
            {
                return(CopyMoveProgressResult.Continue);
            }

            var progressHolder = (ProgressHolder)userData;

            var currentProgressInPercent = totalBytesTransferred * 100 / totalFileSize;

            if (currentProgressInPercent >= progressHolder.Progress + 10)
            {
                progressHolder.Progress = (int)currentProgressInPercent;
                if (_progressQueue.All(p => p.Item1.Name != progressHolder.Name))
                {
                    _progressQueue.Enqueue(Tuple.Create(progressHolder.DriveInfo, progressHolder.Name, progressHolder.Progress));
                }
            }

            return(CopyMoveProgressResult.Continue);
        }
Example #4
0
        private static CopyMoveProgressResult CopyMoveProgressHandler(long totalfilesize, long totalbytestransferred, long streamsize, long streambytestransferred, int streamnumber, CopyMoveProgressCallbackReason callbackreason, object userdata)
        {
            Console.Write($"\r{' ', 100}");

            Console.Write(totalfilesize == totalbytestransferred
                ? "\rTransfer complete!\n"
                : $"\rTotal Size: {totalfilesize}, Transferred: {totalbytestransferred}");
            return(CopyMoveProgressResult.Continue);
        }