int dfsFolder(string folderPath, ofstream &fout)
{
_finddata_t FileInfo;
string strfind = folderPath +"\\*";
long Handle = _findfirst(strfind.c_str(), &FileInfo);
if (Handle == -1L)
{
//cerr << "can not match the folder path" << endl;
exit(-1);
}
do{
//判斷是否有子目錄
if (FileInfo.attrib & _A_SUBDIR)
{
//子目錄
if( (strcmp(FileInfo.name,".") != 0 ) &&(strcmp(FileInfo.name,"..") != 0))
{
string newPath = folderPath + "\\" + FileInfo.name;
dfsFolder(newPath, fout);
}
}
else
{
//此處添加對各個文件的操作
}
}while (_findnext(Handle, &FileInfo) == 0);
_findclose(Handle);
fout.close();
return flag;
}