Date: 2011jan21
Platform: win32
Language: C/C++
Q. How can I check that a path is a directory/folder?
A. Here's a small function that does it.
BOOL IsDir(LPCSTR szDir)
{
DWORD dwAttrib;
if ((dAttrib = GetFileAttributesW(szDir)) == 0xFFFFFFFF) return FALSE;
return (dwAttrib & FILE_ATTRIBUTE_DIRECTORY);
}
void ExampleUse()
{
if (IsDir("C:\\Windows"))
{
printf("c:\\Windows exists and is a folder\n");
}
else
{
printf("c:\\Windows isn't a folder\n");
}
}
| What this info useful to you? You can donate to say thanks |
Add a comment
Sign in to add a comment