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

 

 

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;
}

 

posted @ 2015-04-15 11:59  huhu0013  阅读(322)  评论(0编辑  收藏  举报