RenameFile

 

Description

Rename a file with full path specified for both old and new file names The old file name must point to a valid file that can be renamed and the new file name specified must be a full path in the same folder as the original.

Syntax

BOOL RenameFile( LPCSTR lpcszNewFilename, LPCSTR lpcszOldFilename )

Parameters

lpcszNewFilename
[input]full path file name to rename to
lpcszOldFilename
[input] full path file name of the existing file to rename

Return

TRUE if success

Examples

EX1

void    RenameFile_ex1()
{
    string    str = GetAppPath() + "origin.ini";
    CopyFile(str, GetAppPath() + "junk1.ini");
    string strNewName = GetAppPath() + "junk2.ini";
    ASSERT(!strNewName.IsFile());
    RenameFile(strNewName, GetAppPath() + "junk1.ini");
    ASSERT(strNewName.IsFile());
}

Remark

See Also

header to Include

origin.h

Reference