#include "FindFile.h"
void CFindFileDlg::GetFile(CString sPath, HTREEITEM hParant)
{
if (sPath.IsEmpty())
{
return;
}
CFileFind ff;
CString szDir = sPath;
if(szDir.Right(1) != "\\")
szDir += "\\";
szDir += "*.*";
BOOL res = ff.FindFile(szDir);
while( res )
{
res = ff.FindNextFile();
CString sFileName;
if (ff.IsDirectory() && !ff.IsDots())//文件夹
{
CString sFilePath = ff.GetFilePath();
sFileName = ff.GetFileTitle();
HTREEITEM hItem = m_Tree.InsertItem(sFileName, -1, 1, hParant);
m_Tree.Expand(hParant, TVE_EXPAND);
GetFile(sFilePath, hItem);
}
else if (!ff.IsDirectory() && !ff.IsDots())//文件
{
CString strFilePath = ff.GetFilePath();
CString strTitle = ff.GetFileTitle();
CString strName = ff.GetFileName();
HTREEITEM hItem = m_Tree.InsertItem(strTitle, -1, 1, hParant);
m_Tree.Expand(hParant, TVE_EXPAND);
}
}
ff.Close();
}