MFC:フォルダを巡る

945 ワード



void RecursiveFindFile(CString strRootPath)
{ 
	/* 
	      CFileFind    。
	       ;
	   FindFile()
	   FindNextFile()
	*/
	// strRootPath     ;
	CFileFind finder;
	CString FilePath;
	if ( strRootPath.Right(1) != "/" )
		strRootPath += "/";
	strRootPath += "*.*";

	BOOL res = finder.FindFile(strRootPath);	//     root             ;
	while ( res )		// res 1,    nextFile;
	{
		res = finder.FindNextFile();
		FilePath = finder.GetFilePath();

		if ( finder.IsDots() )	continue;		//      “.” “..”,       ;

		if ( finder.IsDirectory() )		//        ;
		{
			RecursiveFindFile(FilePath);		//   ;
		}
		else if ( !finder.IsDirectory() )		//       ;
		{
			AfxMessageBox(finder.GetFileName());    //      
		}
	}
}