CFile::Rename
This static function renames the specified file.
static void PASCAL Rename(
LPCTSTR lpszOldName,
LPCTSTR lpszNewName
);
Parameters
lpszOldName
The old path.lpszNewName
The new path.
Remarks
Directories cannot be renamed. This is equivalent to the REN command.
Example
TCHAR* pOldName = _T("Oldname_File.dat");
TCHAR* pNewName = _T("Renamed_File.dat");
try
{
CFile::Rename(pOldName, pNewName);
}
catch(CFileException* pEx )
{
TRACE(_T("File %20s not found, cause = %d\n"), pOldName,
pEx->m_cause);
pEx->Delete();
}
Requirements
Header: afx.h