In short, the problem is that it is impossible to get into other disks and folders (higher than the executable file is).
In general, the strong feeling that the function is written is very crooked and not correct. Tell me how to rewrite it correctly
bool Search_File(TCHAR *buffer, char mas[]) { HANDLE file; WIN32_FIND_DATA ffd = {0}; TCHAR temp[MAX_PATH]; TCHAR str[MAX_PATH]; SetCurrentDirectory(buffer);//текуций католог file = FindFirstFile(TEXT(mas),&ffd); if (file == INVALID_HANDLE_VALUE) { cout <<"Файл не был найден"<<endl; return false; } else{ do{ if(!strcmp(ffd.cFileName, TEXT("."))||!strcmp(ffd.cFileName, TEXT(".."))){ continue; } if (ffd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY){//если не установлен бит, тогда файл strcpy(temp, buffer); strcat(temp, "\\"); strcat(temp, ffd.cFileName); Search_File(buffer, mas); strcpy(buffer, temp); continue; } cout<<"найденый файл:"<<ffd.cFileName<<endl; } while(FindNextFile(file,&ffd) != 0); } FindClose(file); return true; }