CFileFind使用Demo

示例代码如下:

CFileFind fFinder;
BOOL bFind = fFinder.FindFile(TEXT("D:/*.*"));
while (bFind)
{
  bFind = fFinder.FindNextFile();

  //当前文件夹及上层文件夹(名称分别为.和..)-----------------
  if (fFinder.IsDots())
  {
    continue;
  }

  //子文件夹---------------------------------------------
  if(fFinder.IsDirectory())
  {
    CString cstrDirName = fFinder.GetFileName(); //directory name
    CString cstrDirPath = fFinder.GetFilePath(); //directory path
    continue;
  }

  //文件-------------------------------------------------
  CString cstrFileName = fFinder.GetFileName(); //file name
  CString cstrFilePath = fFinder.GetFilePath(); //file path
}

fFinder.Close();

posted on 2012-03-03 09:28  wangyao1052  阅读(301)  评论(0编辑  收藏  举报

导航