CopyFileEx (Windows CE 5.0)

Send Feedback

This function copies an existing file to a new file.

BOOLCopyFileEx(LPCTSTRlpExistingFileName, LPCTSTRlpNewFileName,  LPPROGRESS_ROUTINE lpProgressRoutine,  LPVOID lpData,  LPBOOL pbCancel,  DWORD dwCopyFlags);

Parameters

  • lpExistingFileName
    [in] Pointer to a null-terminated string that specifies the name of an existing file.
  • lpNewFileName
    [in] Pointer to a null-terminated string that specifies the name of the new file.
  • lpProgressRoutine
    [in] Address of a callback function that is called each time another portion of the file has been copied. This parameter can be NULL.
  • lpData
    [in] Argument to be passed to the callback function. This parameter can be NULL.
  • pbCancel
    [in] If this parameter is set to TRUE during the copy operation, the operation is canceled. Otherwise, the copy operation continues to completion.
  • dwCopyFlags
    [in] Flags that specify how the file is to be copied. This parameter can be set to any combination of the following values.
    Value Description
    COPY_FILE_ALLOW_DECRYPTED_DESTINATION An attempt to copy an encrypted file will succeed even if the destination copy cannot be encrypted.
    COPY_FILE_FAIL_IF_EXISTS The copy operation fails immediately if the target file already exists.
    COPY_FILE_RESTARTABLE Progress of the copy is tracked in the target file in case the copy fails. The failed copy can be restarted at a later time by specifying the same values for lpExistingFileName and lpNewFileName as those used in the call that failed.

Return Values

If the function succeeds, the return value is nonzero. If the function fails, the return value is zero. To get extended error information, call GetLastError.

Remarks

This function fails with ERROR_ACCESS_DENIED if the destination file already exists and has the FILE_ATTRIBUTE_HIDDEN or FILE_ATTRIBUTE_READONLY set.

If lpProgressRoutine returns PROGRESS_CANCEL due to the user canceling the operation, CopyFileEx will return zero and GetLastError will return ERROR_REQUEST_ABORTED. In this case, the partially copied destination file is deleted.

If lpProgressRoutine returns PROGRESS_STOP due to the user stopping the operation, CopyFileEx will return zero and GetLastError will return ERROR_REQUEST_ABORTED. In this case, the partially copied destination file is left intact.

Requirements

OS Versions: Windows CE 5.0 and later
Header: Winbase.h.
Link Library: Coredll.lib.

See Also

CopyFile | CreateFile | MoveFile | DeleteAndRenameFile

Send Feedback on this topic to the authors

Feedback FAQs

© 2006 Microsoft Corporation. All rights reserved.