It is necessary to implement a search for files / folders in subdirectories. Path is the path to the source folder, argument b is the search mask. The problem is that the algorithm goes through all the folders and subdirectories on the disk, but only finds files from the original Path packs.
void FindFileRecursive(string & Path, char *b, HWND fList) { bool flag = false; static int i = 0; WIN32_FIND_DATA FindData; string Mask = Path + "*"; HANDLE fFind = FindFirstFile(Mask.c_str(), &FindData); if (INVALID_HANDLE_VALUE != fFind) { do { if (Find::IsNotDotName(&FindData.cFileName[0])) { string FullPath = Path + &FindData.cFileName[0] + "\\"; if (Find::IsDirectory(FindData.dwFileAttributes)) FindFileRecursive(FullPath, b, fList); else { _finddata_t fd; int OK = _findfirst(FullPath.c_str(), &fd); int result = OK; INT i = 0; while (result != -1) { char *q = NULL; if (b[0] == '*') { ++b; flag = true; } if (flag) q = strstr(fd.name, b); if (strncmp(b, fd.name, strlen(fd.name)) == 0 || q != NULL) { LVITEM LvItem; memset(&LvItem, 0, sizeof(LvItem)); LvItem.mask = LVIF_TEXT; LvItem.cchTextMax = 256; LvItem.iItem = i; LvItem.iSubItem = 0; LvItem.pszText = fd.name; SendMessage(fList, LVM_INSERTITEM, 0, (LPARAM)&LvItem); char Temp[100]; LvItem.iSubItem = 2; sprintf_s(Temp, "%s", fd.name); LvItem.pszText = Temp; SendMessage(fList, LVM_SETITEM, 0, (LPARAM)&LvItem); LvItem.iSubItem = 3; sprintf_s(Temp, "%f", fd.size); LvItem.pszText = "0"; if (fd.size != NULL) LvItem.pszText = Temp; SendMessage(fList, LVM_SETITEM, 0, (LPARAM)&LvItem); LvItem.iSubItem = 1; ctime_s(Temp, 30, &fd.time_write); LvItem.pszText = Temp; SendMessage(fList, LVM_SETITEM, 0, (LPARAM)&LvItem); i++; } result = _findnext(OK, &fd); } } } } while (NULL != FindNextFile(fFind, &FindData)); } FindClose(fFind); }
$Recycle.Bin, the program may simply not have access rights (check in Explorer). Do not forget after receiving -1 to checkerrno, there is a really happened error. And with the rest of the directories there is no problem? - VladDerrno? - VladD