The following code checks for the existence of a directory on the filesystem.
#define WIN32_LEAN_AND_MEAN #include <windows.h> #ifndef INVALID_FILE_ATTRIBUTES #define INVALID_FILE_ATTRIBUTES ((DWORD)-1) #endif /* Returns TRUE if filename parameter is a directory or FALSE if filename is either NULL or a file */ BOOL IsDir(const char *filename) { DWORD dwAttrs; dwAttrs = GetFileAttributes(filename); if (dwAttrs == INVALID_FILE_ATTRIBUTES) return FALSE; return (BOOL) (dwAttrs & FILE_ATTRIBUTE_DIRECTORY); }