64,680
社区成员
发帖
与我相关
我的任务
分享
BOOL IsRoot(CString str )
{
if ( str.GetLength() == 3 && str.GetAt(str.GetLength()-1) == ':' ) {
return TRUE ;
}
return FALSE ;
}
void FindInAll( CString Path)
{
CString szFind;
szFind=Path;
szFind += _T("\\*.*");
WIN32_FIND_DATA FindFileData;
HANDLE hFind = FindFirstFile( szFind , &FindFileData);
if(hFind==INVALID_HANDLE_VALUE)
return ;
do{
if(FindFileData.cFileName[0] == '.' ) //过滤本级目录和父目录
continue;
CString strFile;
if(IsRoot(Path))
strFile = Path+ FindFileData.cFileName;
else
strFile = Path + _T("\\") + FindFileData.cFileName;
//至于得到目录,包括文件名什么的,很简单的。有例子。
if(FindFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
FindInAll(strFile); //如果找到的是目录,则进入此目录进行递归
}
else { //找到的是文件
//这里按你的需求处理吧,呵呵···希望能帮到你。
}
} while(FindNextFile(hFind,& FindFileData));
FindClose(hFind);
}