本帖最后由 VisualEleven 于 2013-01-11 14:14:02 编辑

解决方案 »

  1.   


    ULONGLONG CFileManager::CalcDirSize( const CString& strDirName)
    {
    CFileFind finder;
    CString strDirFullName(strDirName);
    strDirFullName += _T("\\*.*");
    BOOL bRet = finder.FindFile(strDirFullName);
    ULONGLONG nTotal = 0;
    while (bRet)
    {
    bRet = finder.FindNextFile();
    if (finder.IsDots())
    {
    continue;
    }
    else if (finder.IsDirectory())
    {
    nTotal += CalcDirSize(finder.GetFilePath());

    else
    {
    nTotal += finder.GetLength();
    }
    }
            finder.Close();
    return nTotal;
    }
    计算指定目录大小的代码,楼主可以参考
      

  2.   

    MSDN上关于CFileFind类有例子代码,你自己修改一下即可:
    void Recurse(LPCTSTR pstr)
    {
       CFileFind finder;   // build a string with wildcards
       CString strWildcard(pstr);
       strWildcard += _T("\\*.*");   // start working for files
       BOOL bWorking = finder.FindFile(strWildcard);   while (bWorking)
       {
          bWorking = finder.FindNextFile();      // skip . and .. files; otherwise, we'd
          // recur infinitely!      if (finder.IsDots())
             continue;      // if it's a directory, recursively search it
          CString str = finder.GetFilePath();
          TRACE(_T("%s\n"), (LPCTSTR)str);      if (finder.IsDirectory())
          {
              Recurse(str);
          }
       }   finder.Close();
    }void PrintDirs()
    {
       Recurse(_T("C:"));

      

  3.   

    微软的CFileFind已经帮你实现了, 只需要用while循环就可以找到所有的,不需要递归.
    和回调没什么关系.