CFileFind:
void GetFiles(CString str_Dir, vector<CString> vctfiles)
{
CFileFind fileFinde;
if (str_Dir.Right(1) != "\\") str_Dir += "\\";
str_Dir += "*.*";
BOOL res = fileFinde.FindFile(str_Dir);
while (res)
{
res = fileFinde.FindNextFileW();
if (fileFinde.IsDirectory() && !fileFinde.IsDots())
{
CString strPath = fileFinde.GetFilePath();
GetFile(strPath, vctfiles);
}
else if (!fileFinde.IsDirectory() && !fileFinde.IsDots())
{
CString strPath = fileFinde.GetFilePath();
CString strTile = fileFinde.GetFileName();
vctfiles.push_back(strPath + "\\" + strTile);
}
}
fileFinde.Close();
}
#include <io.h>
struct _finddata_t:
void getFiles(string strUrl, vector<string> vctfiles)
{
struct _finddata_t fileinfo;
long hFile = 0;
string p;
if (_findfirst(p.assign(strUrl).append( + "\\*").c_str(), & fileinfo) != -1)
{
do
{
if (fileinfo.attrib & _A_SUBDIR)
{
if (strcmp(".", fileinfo.name) != 0 && strcmp("..", fileinfo.name) != 0)
{
getFiles(p.assign(strUrl).append(+"\\").append(fileinfo.name), vctfiles);
}
}
else
{
vctfiles.push_back(p.assign(strUrl).append(+"\\").append(fileinfo.name));
}
} while (_findnext(hFile,&fileinfo) == 0);
_findclose(hFile);
}
}