//获得可执行文件所在的路径
CString sText;
TCHAR szPath[MAX_PATH];
ZeroMemory(szPath, sizeof(TCHAR)*MAX_PATH);
GetModuleFileName(NULL, szPath, sizeof(TCHAR)*MAX_PATH);//获得可执行文件位置
LPTSTR pos01 = _tcsrchr(szPath, '\\');
if (pos01 != NULL)
*pos01 = '\0';
CString sFilePath;
sFilePath = CString(szPath) +_T("\\Temp\\*.*");
//查找指定文件夹内的文件并删除
CFileFind fileFinder;
BOOL bFile = fileFinder.FindFile(sFilePath);
while(bFile)
{
bFile = fileFinder.FindNextFile();
if(!fileFinder.IsDirectory() && !fileFinder.IsDots()) //当为文件时;
{
CString strFullName = fileFinder.GetFilePath();
DeleteFile(strFullName);
}
}
fileFinder.Close();//关闭文件查询