判断文件、文件夹是否存在

 

 

BOOL TPubTools::FolderExist(const CString &strPath)
{
WIN32_FIND_DATA wfd;
HANDLE hFind;
BOOL bRet = FALSE;

hFind = FindFirstFile(strPath, &wfd);

if (hFind != INVALID_HANDLE_VALUE)
{
if (wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
{
bRet = TRUE;
}

FindClose(hFind);
}

return bRet;
}

 

BOOL TPubTools::FileExist(const CString &strPath)
{
WIN32_FIND_DATA wfd;
HANDLE hFind;
BOOL bRet = FALSE;

hFind = FindFirstFile(strPath, &wfd);

if (hFind != INVALID_HANDLE_VALUE)
{
if (!(wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY))
{
bRet = TRUE;
}

FindClose(hFind);
}

return bRet;
}

 

你可能感兴趣的:(文件夹)