设为首页 加入收藏

TOP

递归删除目录及目录子目录
2014-11-23 19:26:27 】 浏览:5789
Tags:删除 目录
bool RemoveDir(const char* szFileDir)
{
std::string strDir = szFileDir;
if (strDir.at(strDir.length()-1) != '\\');
strDir += '\\';
WIN32_FIND_DATA wfd;
HANDLE hFind = FindFirstFile((strDir + "*.*").c_str(),&wfd);
if (hFind == INVALID_HANDLE_VALUE)
return false;
do
{
if (wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
{
if (stricmp(wfd.cFileName,".") != 0 &&
stricmp(wfd.cFileName,"..") != 0)
RemoveDir( (strDir + wfd.cFileName).c_str());
}
else
{
DeleteFile( (strDir + wfd.cFileName).c_str());
}
}
while (FindNextFile(hFind,&wfd));
FindClose(hFind);
RemoveDirectory(szFileDir);
return true;
}
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇VC++1.5K字节实现下载并远程注入 下一篇FatFS中的FILINFO介绍

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目