FolderExists()

Monday, June 26, 2006
I haven't found a good method to check if a folder exists in non-managed C++, so I thought I'd post what I came up with. This also works with Windows CE, too.

bool FolderExists(TCHAR *szPath)
{
DWORD dwAttr = GetFileAttributes(szPath);
if (dwAttr & FILE_ATTRIBUTE_DIRECTORY)
{
return TRUE;
}
return FALSE;
}


Bear in mind, however, that this could also return false if there was a permissions error. I'll let you expand upon it as like.
Older Post Home Newer Post