Compartilhar via


CFile::Remove

This static function deletes the file specified by the path.

static void PASCAL Remove(
   LPCTSTR lpszFileName,
   CAtlTransactionManager* pTM = NULL
);

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.

  • pTM
    Pointer to CAtlTransactionManager object

Remarks

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

//example for CFile::Remove
TCHAR* pFileName = _T("Remove_File.dat");
try
{
   CFile::Remove(pFileName);
}
catch (CFileException* pEx)
{
   TRACE(_T("File %20s cannot be removed\n"), pFileName);
   pEx->Delete();
}

Requirements

Header: afx.h

See Also

Reference

CFile Class

Hierarchy Chart

Other Resources

CFile Members