[C++] How do I check if a directory is a file or folder?
bool IsDirectory(const wchar_t* filename)
{
if ((GetFileAttributesW(filename) & FILE_ATTRIBUTE_DIRECTORY) == FILE_ATTRIBUTE_DIRECTORY)
return true;
else
return false;
}
bool IsDirectory(const char* filename)
{
if ((GetFileAttributes(filename) & FILE_ATTRIBUTE_DIRECTORY) == FILE_ATTRIBUTE_DIRECTORY)
return true;
else
return false;
}
//-----------------------------------------------
#include "Shlwapi.h"
#pragma comment(lib , "Shlwapi.lib")
BOOL IsDirectory(LPCTSTR pszPath)
{
return PathIsDirectory(pszPath);
)