Copy/Move with reporting progress

Mar 12, 2014 at 4:34 PM
Can you give me an example how to use your copy/move method with the
CopyMoveProgressCallback and UserProgressData to report progress from the BackgroundWorker?
Developer
Mar 13, 2014 at 9:50 AM
Mar 13, 2014 at 3:32 PM
According to the link this should work but File.Copy is not happy with the Callback.
File.Copy(source, destination, CopyOptions.None, true, new CopyMoveProgressCallback(CopyProgressHandler), null);
where
private CopyMoveProgressResult CopyProgressHandler(long total, long transferred, long streamSize, long StreamByteTrans, uint dwStreamNumber, CopyMoveProgressCallbackReason reason, IntPtr hSourceFile, IntPtr hDestinationFile, IntPtr lpData)
        {
            switch (reason)
            {
                case CopyMoveProgressCallbackReason.ChunkFinished:                    
                    EventCopyHandler...
                    return m_bCancel ? CopyMoveProgressResult.Cancel : CopyMoveProgressResult.Continue;
                default:
                    return CopyMoveProgressResult.Continue;
            }
        }
Mar 15, 2014 at 6:02 PM
Edited Mar 15, 2014 at 7:04 PM
I think I figured out callback but i can not figure out what kind of object is userProgressData
File.Copy(sourceFile, destFile, CopyOptions.None, true, myCallback, userProgressData);
Developer
Mar 15, 2014 at 8:08 PM
userProgressData: "The argument to be passed to the callback function. This parameter can be null."

So if your callback function doesn't require any data, just supply null.

Yomodo