当前位置:首页
开发技术指南» 文章正文
    引言:
 

 

 ·    »显示摘要«
    摘要: rt ......
    摘要: 如题,谈谈程序员文化与人文精神 ......


如何获得一个指定目录中的文件个数

如何获得一个指定目录中的文件个数?以及制定的文件后缀的个数

NO.1   作者: wl3c

int   count;  
   
  int   CGetFileCountDlg::GetFileCount(CString   szPath)  
  {  
  count     =   0;  
  Recurse(szPath);  
  return   count;  
  }  
  void   CGetFileCountDlg::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();  
   
              if   (finder.IsDots())     //判断是否是文件  
                    continue;  
  if(!finder.IsDirectory())  
                  {  
          count   ++;  
                  }  
              //   if   its   a   directory,   recursively   search   it  
              if   (finder.IsDirectory())   //判断是否是文件夹   //路径  
              {  
                    CString   str   =   finder.GetFilePath();  
                    Recurse(str);  
              }  
   
        }  
   
        finder.Close();  
  }  
   
  count   就是目录下文件的个数


    摘要: 哪有《opengl超级宝典》电子版下载?? ......
» 本期热门文章:

©2000-2007 All Rights Reserved. 最佳浏览:1024X768 MSIE