CopyFile

This function copies an existing file to a new file. A remote application interface (RAPI) version of this function exists, named CeCopyFile.

BOOL CopyFile(
LPCTSTR lpExistingFileName, 
LPCTSTR lpNewFileName, 
BOOL bFailIfExists ); 

Parameters

  • lpExistingFileName
    [in] Long pointer to a null-terminated string that specifies the name of an existing file.
  • lpNewFileName
    [in] Long pointer to a null-terminated string that specifies the name of the new file.
  • bFailIfExists
    [in] Boolean that specifies how this operation is to proceed if a file of the same name as that specified by lpNewFileName already exists. If this parameter is TRUE and the new file already exists, the function fails. If this parameter is FALSE and the new file already exists, the function overwrites the existing file and succeeds.

Return Values

Nonzero indicates success. Zero indicates failure. To get extended error information, call GetLastError.

Remarks

Security attributes for the existing file are not copied to the new file.

File attributes for the existing file are copied to the new file. For example, if an existing file has the FILE_ATTRIBUTE_READONLY file attribute, a copy created through a call to CopyFile will also have the FILE_ATTRIBUTE_READONLY file attribute. For more information about file attributes, see CreateFile.

To store the maximum number of files on PC Card storage devices, limit file names to eight uppercase characters and file extensions to three uppercase characters. Also, do not allow non-OEM characters in file names. File names that do not conform to these limits require more than one physical directory entry on a PC Card.

CopyFile does not operate on directories.

Requirements

Runs on Versions Defined in Include Link to
Windows CE OS 1.0 and later Winbase.h   Coredll.lib, Fsmain.lib

Note   This API is part of the complete Windows CE OS package as provided by Microsoft. The functionality of a particular platform is determined by the original equipment manufacturer (OEM) and some devices may not support this API.

See Also

CeCopyFile, CreateFile, GetLastError, MoveFile

 Last updated on Tuesday, July 13, 2004

© 1992-2000 Microsoft Corporation. All rights reserved.