2.1.10.10 FileCopy


Description

Copy file and also set destination file's attribute

Syntax

BOOL FileCopy( LPCSTR lpcszSrc, LPCSTR lpcszDest, DWORD dwAttribute = FILE_ATTRIBUTE_NORMAL, bool bSetCurrentTime = false )

Parameters

lpcszSrc
[input] Pointer to a null-terminated string that specifies the name of an existing file.
lpcszDest
[input] Pointer to a null-terminated string that specifies the name of the new file.
dwAttribute
[input] the file attribute to set on the new file lpcszDest
bSetCurrentTime
[input] set the destination file to the current time or not

Return

Returns TRUE for success, otherwiseFALSE.

Examples

EX1

int FileCopy_ex1()
{
    string strExePath = GetAppPath();
    if( strExePath.IsEmpty())
        return 1;
    StringArray saResult;
    FindFiles(saResult, strExePath, "txt");
    if( saResult.GetSize() > 0)
    {
        string    strCopyFrom=strExePath+saResult[0],
                strCopyTo=strExePath+"temp.txt";
        FileCopy(strCopyFrom,strCopyTo,FILE_ATTRIBUTE_NORMAL,true);
        printf("the new file is created in %s",GetFileModificationDate(strCopyTo));
    }
    return 0;
}

Remark

This function will call CopyFile with default bFailIfExists = FALSE

See Also

Header to Include

origin.h

Reference