清除系统临时目录里的文件和目录

作者: admin 分类: win32 发布时间: 2013-07-11 21:20 ė2,165 浏览数 6没有评论
文章转自王牌软件
站长推荐:NSetup一键部署软件
一键式完成美化安装包制作,自动增量升级,数据统计,数字签名。应对各种复杂场景,脚本模块化拆分,常规复杂的脚本代码,图形化设置。无需专业的研发经验,轻松完成项目部署。(www.nsetup.cn)

#include <deque>
using namespace std;
TCHAR lpPath[MAX_PATH];
memset(lpPath,0,MAX_PATH);
GetTempPath(MAX_PATH,lpPath);
deque<CString>delfiles;
deque<CString>folderList;
CString path;
path.Format(“%s\\*.*”,lpPath);
delfiles.push_back(path);
while (delfiles.size()>0)
{
CFileFind delfinder;
BOOL bWorking = delfinder.FindFile(delfiles.front());
folderList.push_back(delfiles.front());
delfiles.pop_front();
while (bWorking)
{
bWorking = delfinder.FindNextFile();
if(!delfinder.IsDots())
{
CString pathfile=delfinder.GetFilePath();
if(delfinder.IsDirectory())
{
CString filename;
filename.Format(“%s\\*.*”,delfinder.GetFilePath());
CFileFind delfd;
BOOL aWorking = delfd.FindFile(filename);
while(aWorking)
{
aWorking = delfd.FindNextFile();
CString filepath=delfd.GetFilePath();
if(!delfd.IsDots())
{
if(delfd.IsDirectory())
delfiles.push_back(filepath);
else
DeleteFile(filepath);
}
}
delfd.Close();
}
else
DeleteFile(pathfile);
}
}
delfinder.Close();
}
while(folderList.size()>1)
{
CString filepath=folderList.back();
CString folder=filepath;
folder.Replace(“\\*.*”,””);
if(RemoveDirectory(folder))
folderList.pop_back();
else
{
CFileFind finder;
BOOL bWorking = finder.FindFile(folderList.back());
while (bWorking)
{
bWorking = finder.FindNextFile();
if(finder.IsDirectory() && !finder.IsDots())
folderList.push_back(finder.GetFilePath());
}
finder.Close();
}
}



只回答业务咨询点击这里给我发消息 点击这里给我发消息

王牌软件,兼职软件设计,软件修改,毕业设计。

本文出自 王牌软件,转载时请注明出处及相应链接。

本文永久链接: http://www.softwareace.cn/?p=503

0

发表评论

电子邮件地址不会被公开。 必填项已用*标注

您可以使用这些HTML标签和属性: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">


Ɣ回顶部

无觅相关文章插件,快速提升流量