VC删除文件夹下所有文件

来源:互联网 发布:淘宝电话客服转人工 编辑:程序博客网 时间:2024/04/30 12:26
 
void DEL_DIR(CString str)
{
  CFileFind cfind;
wchar_t temCh[500];
wcscpy(temCh,str.GetBuffer());
wcscat(temCh,L"//*.*");
BOOL bFind = cfind.FindFile(temCh);
while(bFind)
{
bFind = cfind.FindNextFile();
if(!cfind.IsDots())
{
if(cfind.IsDirectory())
{
DEL_DIR(cfind.GetFilePath());
}
else
{
if(DeleteFile(cfind.GetFilePath().GetBuffer()))
{
//MessageBox(NULL,LPCWSTR(temPath),L"提示",0);
}
}
}
}
if(!RemoveDirectory(str))
{
//MessageBox(NULL,L"删除失败",L"提示",0);
}
    }
原创粉丝点击