I´m trying to build a method to see if a file exists. the method in it´s current isn´t complete form. i´m trying to figur out whyy it doesn´t behave as code.
BOOL FileExists(LPCTSTR szPath)
{
//MessageBox(NULL,szPath,L"File Error",MB_OK);
DWORD dwAttrib = GetFileAttributes(szPath);
switch(dwAttrib)
{
case FILE_ATTRIBUTE_DIRECTORY:
MessageBox(NULL,L"FILE_ATTRIBUTE_DIRECTORY",L"File Error",MB_OK);
break;
case FILE_ATTRIBUTE_ARCHIVE:
MessageBox(NULL,L"FILE_ATTRIBUTE_ARCHIVE",L"File Error",MB_OK);
break;
case FILE_READ_ONLY_VOLUME:
MessageBox(NULL,L"FILE_READ_ONLY_VOLUME",L"File Error",MB_OK);
break;
case FILE_INVALID_FILE_ID:
MessageBox(NULL,L"FILE_INVALID_FILE_ID",L"File Error",MB_OK);
break;
default:
MessageBox(NULL,(LPCWSTR)dwAttrib,L"File Error",MB_OK);
break;
}
return true;
}
this is how i call the method:
FileExists((LPCWSTR)path.c_str());
this is where my file resides:
std::string path = "C:\\smiley.bmp"
i always end up here, no mather in what order the switched is coded:
FILE_INVALID_FILE_ID
i'm wondering if i'm typecastings correct to "LPCTSTR"
.
Because i tried using a MessageBox to display the contents of "szPath"
and it showed up as human unreadeble format.
the path i provide is correct, properly escaped.
how can i check if "szPath"
contains the proper information?