共用方式為


CFile::Rename

staticvoidPASCALRename(LPCTSTRlpszOldName**,LPCTSTRlpszNewName);**
throw(CFileException);

Parameters

lpszOldName

The old path.

lpszNewName

The new path.

Remarks

This static function renames the specified file. Directories cannot be renamed. This is equivalent to the REN command.

Example

//example for CFile::Rename
extern char* pOldName;
extern char* pNewName;
TRY
{
    CFile::Rename( pOldName, pNewName );
}
CATCH( CFileException, e )
{
    #ifdef _DEBUG
        afxDump << "File " << pOldName << " not found, cause = "
            << e->m_cause << "\n";
    #endif
}
END_CATCH

CFile OverviewClass MembersHierarchy Chart