Tuesday, December 7, 2010

Cancelling the file copy

Tip - Use CopyFileEx if the file copy is supposed to be cancelled/stopped conditionally.
Details  -
CopyFileEx provides an option to register progress call-back during the copy operation. And the return value of this call-back function can be used to  control  the copy operation. This API is useful for the graceful exit of application threads on application closure, rather than leaving the files being copied in an undefined state.

The table below shows relevant return values for the call-back function. We can control the copy operation by using these values.


Return code/value
Description
PROGRESS_CANCEL
Cancel the copy operation and delete the destination file.
1
PROGRESS_CONTINUE
Continue the copy operation.
0
PROGRESS_QUIET
Continue the copy operation, but stop invoking the call-back to report progress.
3

PROGRESS_STOP
Stop the copy operation. It can be restarted at a later time.
2


Reference         -

Posted By :Praveen E

No comments:

Post a Comment