consider the following example
#include <windows.h>
#include <iostream>
using namespace std;
bool exists(char* filePath)
{
DWORD fileAtt = GetFileAttributesA(filePath);
if(fileAtt == INVALID_FILE_ATTRIBUTES)
throw GetLastError();
return ( ( fileAtt & FILE_ATTRIBUTE_DIRECTORY ) == 0 );
}
int main()
{
if (exists("test.txt"))
cout << "test.txt exists!\n";
else
cout << "test.txt does not exists!\n";
return 0;
}</iostream></windows.h>
use this code, you can ensuare file exist or not. if it is exist
you can use
CFile::Remove