CFileFind           finder;
CString             path;
CString           strFileTitle; BOOL bWorking = finder.FindFile("C\\*.*");

         while(bWorking) 

bWorking=finder.FindNextFile(); 
strFileTitle=finder.GetFileTitle(); 

觉得好像没错我跟踪每次bWorking 的值都是0.帮忙看哪有问题。。谢谢。。

解决方案 »

  1.   


    遍历目录void CFileTreeDlg::BrowseFile(CString strFile)
    {

    CFileFind ff;
    CString szDir = strFile;

    if(szDir.Right(1) != "\\")
    szDir += "\\";

    szDir += "*.*";

    BOOL res = ff.FindFile(szDir);
    while(res)
    {
    res = ff.FindNextFile();
    if(ff.IsDirectory() && !ff.IsDots())
    {
    //如果是一个子目录,用递归继续往深一层找
    CString strPath = ff.GetFilePath();
    // CString strTitle = ff.GetFileTitle();

    BrowseFile(strPath);
    }
    else if(!ff.IsDirectory() && !ff.IsDots())
    {
    //显示当前访问的文件
    // CString strPath;
    // CString strTitle;
    // strPath = ff.GetFilePath();
    // strTitle = ff.GetFileTitle();

    }
    }
    ff.Close();//关闭
    }