Possible Duplicate:
How can we check if a file Exists or not using Win32 program?
Which is the best method for checking for file existence:
Option1:
GetFileAttributes("C:\\MyFile.txt"); // from winbase.h
if(0xffffffff == GetFileAttributes("C:\\MyFile.txt"))
{
//File not found
}
Option2:
std::string fileName("C:\\MyFile.txt" );
ifstream fin( fileName.c_str() );
if( fin.fail() )
{
//File not found
}
Also if you think option 1 is the better method, can you tell me how to define 0xffffffff
as a constant (I don't want to use #define)
Thanks