您的位置:首页 > 其它

递归文件夹下所有文件

2014-07-23 15:31 155 查看
void DealFileInterfaceImpl::RecursionToFind(CString strTempPath,FILELIST& sfilelist)
{
CString strPath = strTempPath + ALL_FILE;
CString strTmp = _T("");
TARGETFILE sFile;
char* s_char = NULL;

CFileFind tempFind;
BOOL bFound;
bFound=tempFind.FindFile(strPath);

while(bFound)							//遍历所有文件
{
bFound=tempFind.FindNextFile();
if(tempFind.IsDots())				//如果找到的是当前或者上层目录则结束本次查找
{
continue;
}

if(tempFind.IsDirectory())			//找到的是文件夹,则遍历该文件夹下的文件
{
//USES_CONVERSION;
//strTmp = tempFind.GetFileName();
//s_char = W2A(strTmp);
//sFile.strFileName = s_char;
strTmp=tempFind.GetFilePath();
//s_char=W2A(strTmp);
//sFile.strFilePath = s_char;
//sfilelist.push_back(sFile);
RecursionToFind(strTmp,sfilelist);//递归调用
}
else
{
USES_CONVERSION;

strTmp = tempFind.GetFileName();
s_char = W2A(strTmp);
sFile.strFileName = s_char;

strTmp=tempFind.GetFilePath();
s_char=W2A(strTmp);
sFile.strFilePath = s_char;

boost::hash<std::string> string_hash;
std::string strFileID = s_char;
sFile.ulFilesID = string_hash(strFileID);

s_char=W2A(CMD5Checksum::GetMD5(strTmp));
sFile.strFilesMD5 = s_char;

sfilelist.push_back(sFile);
}
}
tempFind.Close();
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: