遍历某路径下所有文件夹和文件

使用CFileFind类实现,其头文件为afx.h.

 

获得当前可执行文件的路径:

TCHAR   exeFullPath[100];

       GetModuleFileName(NULL,exeFullPath,100);

 

获取当前可执行文件所在文件夹:

CString   sName;

       sName.Format( _T("%s "),exeFullPath);///当前文件全路径名。

       int n  = sName.ReverseFind( '\\');

       sName=sName.Left(sName.ReverseFind( '\\') + 1);///去除文件名部分。

 

CFileFind::IsDots

Nonzero if the found file has the name "." or "..", which indicates that the found file is actually a directory. Otherwise 0.

 

采用递归的方法进行遍历:


 posted on 2011-03-05 16:21  Jiang, X.  阅读(566)  评论(0编辑  收藏  举报