次の方法で共有


CopyFile (Compact 2013)

3/26/2014

This function copies an existing file to a new file.

Syntax

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 set to TRUE and the new file already exists, the function fails. If this parameter is set to FALSE and the new file already exists, the function overwrites the existing file and succeeds.

Return Value

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

Remarks

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 this function also has FILE_ATTRIBUTE_READONLY. For more information, see CreateFile.

This function does not operate on directories.

Requirements

Header

winbase.h

Library

coredll.lib

See Also

Reference

File I/O Functions
CreateFile
MoveFile
DeleteAndRenameFile