清除系统临时目录里的文件和目录
站长推荐: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();
}
}
学习日记,兼职软件设计,软件修改,毕业设计。
本文出自 学习日记,转载时请注明出处及相应链接。
本文永久链接: https://www.softwareace.cn/?p=503