FindFiles
-
hi all, Please see the function below, and let me know if there is something wrong. It is working, but i don't know if this is the correct way. void ListFiles(CString strFolder) { WIN32_FIND_DATA wfd; HANDLE handle = FindFirstFile(strFolder+_T("\\*.*"),&wfd); if(INVALID_HANDLE_VALUE != handle) { do { if(!(wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) { //do some thing with func } else { //check if it is . or .. BOOL bIsDot = FALSE; if (wfd.cFileName[0] == '.') { if (wfd.cFileName[1] == '\0' || (wfd.cFileName[1] == '.' && wfd.cFileName[2] == '\0')) { bIsDot = TRUE; } } if(!bIsDot) ListFiles(strFolder + _T("\\") + wfd.cFileName); } }while (FindNextFile(handle,&wfd)); FindClose( handle ); } } Hari Krishnan
-
hi all, Please see the function below, and let me know if there is something wrong. It is working, but i don't know if this is the correct way. void ListFiles(CString strFolder) { WIN32_FIND_DATA wfd; HANDLE handle = FindFirstFile(strFolder+_T("\\*.*"),&wfd); if(INVALID_HANDLE_VALUE != handle) { do { if(!(wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) { //do some thing with func } else { //check if it is . or .. BOOL bIsDot = FALSE; if (wfd.cFileName[0] == '.') { if (wfd.cFileName[1] == '\0' || (wfd.cFileName[1] == '.' && wfd.cFileName[2] == '\0')) { bIsDot = TRUE; } } if(!bIsDot) ListFiles(strFolder + _T("\\") + wfd.cFileName); } }while (FindNextFile(handle,&wfd)); FindClose( handle ); } } Hari Krishnan
Looks OK to me. INTP