//搜索当前目录下所存在的配置文件,返回文件个数
int CNewsPaperDlg::Find_special_File(LPCTSTR pszPath, //查找起始路径
LPCTSTR pszExt, //文件扩展名
BOOL include_subDirectory, //搜索子目录标志
CComboBox *pBox) //列表
{
//int found_count = 0;
m_iXmlCount = 0;//查找计数器
int file_fliter_len = CString(pszExt).GetLength(); //文件扩展名长度
CString target_file = pszPath; //目标路径
if(target_file.GetLength() > 1 && target_file.Right(1) != '//')
target_file += '//';
if(include_subDirectory) //包括子目录
target_file += "*.*";
else
target_file += pszExt;
bool b_find_all_file = false; //查找所有文件指示
if(CString(pszExt) == ".*") //扩展名使用通配符
&

本文介绍了一种使用MFC在当前目录及其子目录中搜索指定扩展名文件的方法,将找到的文件名添加到组合框中,并返回文件总数。关键代码展示了如何递归遍历目录,筛选匹配的文件并存储结果。
最低0.47元/天 解锁文章

被折叠的 条评论
为什么被折叠?



