CFile::Remove
The document is archived and information here might be outdated

CFile::Remove 

This static function deletes the file specified by the path.


static void PASCAL Remove(
   LPCTSTR lpszFileName 
);

Parameters

lpszFileName

A string that is the path to the desired file. The path can be relative or absolute, and can contain a network name.

It will not remove a directory.

The Remove member function throws an exception if the connected file is open or if the file cannot be removed. This is equivalent to the DEL command.

//example for CFile::Remove
TCHAR* pFileName = _T("test.dat");
try
{
    CFile::Remove(pFileName);
}
catch (CFileException* pEx)
{
#ifdef _DEBUG
    afxDump << "File " << pFileName << " cannot be removed\n";
#endif
   pEx->Delete();
}
Show:
© 2016 Microsoft