I have a project with something similar to what you want, take a look
int HYPNOS_Remote_Manip::HYPNOS_FOLDER_DOWNLOAD(std::string dir_remote, Socket_Setup &socket_setup)
{
HANDLE dir;
WIN32_FIND_DATA file_data;
if ((dir = FindFirstFile((dir_remote + "\\*").c_str(), &file_data)) == INVALID_HANDLE_VALUE)
return 1; /* No files found */
do
{
std::string file_name = file_data.cFileName;
std::string full_file_name = dir_remote + "\\" + file_name;
const bool is_directory = (file_data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0;
if (file_name[0] == '.')
continue;
if (is_directory)
continue;
if (file_name == "desktop.ini")
continue;
int iResult = send(socket_setup.ConnectSocket, file_name.c_str(), strlen(file_name.c_str()), 0); // Meio obvio, aqui você envia o nome do arquivo para o servidor
if (iResult == SOCKET_ERROR)
break;
else
HYPNOS_FILE_DOWNLOAD(full_file_name, socket_setup); // aqui é a função onde você passa o diretório do arquivo em que será enviado para o servidor
} while (FindNextFile(dir, &file_data));
FindClose(dir);
return 0;
}
Assuming your code is structured, an idea to solve the problem is: 1) Read the file names in that directory; 2) execute the code you already have in a loop to process each of the files read in step 1)
– bruno