MFC CFileFind类

void CPrintPortDlg::BrowseDir(CString strDir)
{
CFileFind cFind;
CString szDir = strDir;
if(szDir.Right(1) != "\\")
szDir += "\\";
szDir += "*.*";

BOOL res = cFind.FindFile(szDir);

while(res)
{
res = cFind.FindNextFile();

if(cFind.IsDirectory() && !cFind.IsDots())
{
CString str2 = cFind.GetFileName();
cout< BrowseDir(cFind.GetFilePath());
}
else if(!cFind.IsDirectory() && !cFind.IsDots())
{
CString str = cFind.GetFileName();
CListBox *pCtrl = (CListBox *) GetDlgItem( IDC_LIST1 ) ;
pCtrl->AddString( _T(str) );
}

}

cFind.Close();

}

你可能感兴趣的:(C++)