用tree显示所有文件?

来源:百度知道 编辑:UC知道 时间:2024/05/12 02:13:42
要求显示所有隐藏的

主要算法如下:
void CFileTreeDlg::AddFile(CString StrPath, HTREEITEM faItem )
//StrPath为传递过来的目录层次,本次函数调用中搜索的文件都是它的下一层的。
//faItem为传递过来的Tree节点,本次函数调用中添加的Tree节点都是它的子节点。
{
CFileFind OneFile;
CString FName, DirName;
BOOL BeWorking;
HTREEITEM NewItem;

DirName = StrPath+"\\*.*";
BeWorking = OneFile.FindFile( DirName );
while ( BeWorking ) { //BeWorking非零,指找了文件或目录

//查找同级的目录
BeWorking = OneFile.FindNextFile();

if ( OneFile.IsDirectory() && !OneFile.IsDots() ) //如果查找的结果是目录又不是".."或"."
{
//向Tree1中添加目录;
DirName = OneFile.GetFilePath();
FName = OneFile.GetFileTitle();
//IDC_TREE1
NewItem = m_Tree.InsertItem( FName, faItem ); //NewItem取得节点