zl程序教程

您现在的位置是:首页 >  其他

当前栏目

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

文件 判断 是否 文件夹 存在
2023-09-27 14:20:10 时间

 

 

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