![](https://i-blog.csdnimg.cn/blog_migrate/8f900a89c6347c561fdf2122f13be562.gif)
![ExpandedBlockStart.gif](https://i-blog.csdnimg.cn/blog_migrate/961ddebeb323a10fe0623af514929fc1.gif)
void
CWhiteInputTool_VCDlg::SearchFile(CString strDir)
{
CFileFind ff;
CString szDir = strDir;
if (szDir.Right( 1 ) != _T( " \\ " ))
szDir += _T( " \\ " );
szDir += _T( " *.* " );
BOOL res = ff.FindFile(szDir);
while (res)
{
res = ff.FindNextFile();
if (ff.IsDirectory() && ! ff.IsDots()) // 目录是文件夹
{
// 如果是一个子目录,用递归继续往深一层找
CString strPath = ff.GetFilePath();
// 得到路径,做为递归调用的开始
CString strTitle = ff.GetFileName();
// 得到目录名
SOFTPATH softpath;
softpath.strFileName = strTitle;
softpath.strFilePath = strPath;
m_list_softpath.push_back(softpath);
SearchFile(strPath); // 递归调用
}
else if ( ! ff.IsDirectory() && ! ff.IsDots()) // 到达最低层的文件
{
CString strPath;
CString strTitle;
strPath = ff.GetFilePath();
strTitle = ff.GetFileName();
SOFTPATH softpath;
softpath.strFileName = strTitle;
softpath.strFilePath = strPath;
m_list_softpath.push_back(softpath);;
}
}
ff.Close(); // 关闭
}
{
CFileFind ff;
CString szDir = strDir;
if (szDir.Right( 1 ) != _T( " \\ " ))
szDir += _T( " \\ " );
szDir += _T( " *.* " );
BOOL res = ff.FindFile(szDir);
while (res)
{
res = ff.FindNextFile();
if (ff.IsDirectory() && ! ff.IsDots()) // 目录是文件夹
{
// 如果是一个子目录,用递归继续往深一层找
CString strPath = ff.GetFilePath();
// 得到路径,做为递归调用的开始
CString strTitle = ff.GetFileName();
// 得到目录名
SOFTPATH softpath;
softpath.strFileName = strTitle;
softpath.strFilePath = strPath;
m_list_softpath.push_back(softpath);
SearchFile(strPath); // 递归调用
}
else if ( ! ff.IsDirectory() && ! ff.IsDots()) // 到达最低层的文件
{
CString strPath;
CString strTitle;
strPath = ff.GetFilePath();
strTitle = ff.GetFileName();
SOFTPATH softpath;
softpath.strFileName = strTitle;
softpath.strFilePath = strPath;
m_list_softpath.push_back(softpath);;
}
}
ff.Close(); // 关闭
}