循环变量文件夹中的文件

来源:互联网 发布:1hhhh最新区域名 编辑:程序博客网 时间:2024/06/05 22:57
void AddAttachment(CString FilePath) //去找到临时文件夹中名字中含有"_log.zip"结束的文件
{
CFileFind objfinder; // 文件查找对象
CString  cstrFilePath; // 下一个文件
CString cstrPath = FilePath + _T("\\*.*");
BOOL bFind; // 查找标记


CTime tempTime;


bFind = objfinder.FindFile(cstrPath);


// 目录不存在
if ( !bFind )
{
objfinder.Close();
//return FALSE;
}
// 目录存在
while ( bFind )
{
bFind = objfinder.FindNextFile(); // 如果是目录 递归文件夹底下的所有文件
if (objfinder.IsDots()) // 判断是否为.或..过滤
{
bFind = objfinder.FindNextFile();
continue;
}
if(objfinder.IsDirectory())
{
CString cstrFilePath = objfinder.GetFilePath();
AddAttachment(cstrFilePath);
}
else
{
cstrFilePath = objfinder.GetFileName();//循环去查找文件路径


if (cstrFilePath.Find(".rar") != -1)
{
CMySmtp::stPathFile stTemp; 
stTemp.Path = FilePath; 
stTemp.File = cstrFilePath; 
g_listAttachmentFileName.push_back( stTemp );
}


}




} // end while


objfinder.Close();
//return TRUE;
}
原创粉丝点击