特别需要注意的是,每个文件夹下有.和..两个文件夹分别代表当前目录和上级目录(根目录的..代表当前目录)…IsDot就是用来检测当前是不是.或..的函数

void GetConfigFiles(std::vector & vecFiles)
{
// 获取EXE文件路径
char chPath[MAX_PATH];
GetModuleFileName(NULL,chPath,MAX_PATH);
CString sDirectoryPath = chPath;
int nCount = sDirectoryPath.ReverseFind('');
sDirectoryPath = sDirectoryPath.Mid(0, nCount + 1);
 
// 分类配置固定在confg 下面
sDirectoryPath += _T("config\*.*");
 
CFileFind finder;
std::string sr = _T(".XML");
BOOL bWorking = finder.FindFile(sDirectoryPath);
while (bWorking)
{
bWorking = finder.FindNextFile();
// .或者..
if (finder.IsDots())
continue;
 
// 目录
if (finder.IsDirectory())
continue;
 
//文件
std::string mystr(finder.GetFileName().GetBuffer());
boost::to_upper(mystr);
if(mystr.find(sr) != -1)
{
vecFiles.push_back(mystr);
}
}
 
finder.Close();
}