How to Check the Existence of a File or a Directory

How to Check the Existence of a File or a Directory
BOOL FileExists(LPCTSTR lpFileName)
{
    DWORD dwFileAttr = GetFileAttributes(lpFileName);

    if ((dwFileAttr != 0xFFFFFFFF) &&
        !(dwFileAttr & FILE_ATTRIBUTE_DIRECTORY))
        return TRUE;
    else
        return FALSE;
}
BOOL DirectoryExists(LPCTSTR lpDirectoryName) { DWORD dwFileAttr = GetFileAttributes(lpDirectoryName); if ((dwFileAttr != 0xFFFFFFFF) && (dwFileAttr & FILE_ATTRIBUTE_DIRECTORY)) return TRUE; else return FALSE; } 

你可能感兴趣的:(How to Check the Existence of a File or a Directory)