应该怎么样遍历一个文件夹里面的所以有文件,包括文件夹。

解决方案 »

  1.   

    http://community.csdn.net/Expert/topic/3275/3275649.xml?temp=.4966394
      

  2.   

    CFileFind 然后判断是文件还是文件夹
      

  3.   

    void CSDIDemoView::InitializeSystemImageList() 
     {   
    //通过Sheel初始化
    HIMAGELIST  hSystemSmallImageList, hSystemLargeImageList;  
    SHFILEINFO    ssfi, lsfi;     //get a handle to the system small icon list 
    hSystemSmallImageList =    (HIMAGELIST)SHGetFileInfo(    (LPCTSTR)_T("C:\\"),    0,    &ssfi,    sizeof(SHFILEINFO),    SHGFI_SYSICONINDEX | SHGFI_SMALLICON);  //attach it to the small image list  //--DON'T FORGET TO PUT 
    m_smallImageList.Detach();  // your destructor  
    m_smallImageList.Attach(hSystemSmallImageList);    //do the same for the large 
    hSystemLargeImageList =    (HIMAGELIST)SHGetFileInfo(    (LPCTSTR)_T("C:\\"),    0,    &lsfi,    sizeof(SHFILEINFO),    SHGFI_SYSICONINDEX | SHGFI_ICON); 
    m_largeImageList.Attach(hSystemLargeImageList);    //Set the list control image list  
    m_ctrlList.SetImageList(&m_smallImageList, LVSIL_SMALL); 
    m_ctrlList.SetImageList(&m_largeImageList, LVSIL_NORMAL); 
    folder=m_largeImageList.Add(AfxGetApp()->LoadIcon (IDI_ICON1)); //自定义目录的图标
    }int CSDIDemoView::GetIconIndex(const CString &csFileName)
    {
    //返回指定的文件的对象图标引索
    SHFILEINFO sfi;
    SHGetFileInfo((LPCTSTR)csFileName,0, &sfi,sizeof(SHFILEINFO),SHGFI_SYSICONINDEX | SHGFI_SMALLICON );
    return sfi.iIcon;
    }CFileFind 然后判断是文件还是文件夹