遍历指定目录下所有文件

std::string src_file = "D:\\*.*";
WIN32_FIND_DATA find_data;
HANDLE file_find_handle = FindFirstFile(src_file.c_str(), &find_data);
if (INVALID_HANDLE_VALUE == file_find_handle)
{
    return 0;
}

do
{
    if (find_data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
    {
        continue;
    }

    // do something.
    find_data.cFileName;

} while (FindNextFile(file_find_handle, &find_data));

FindClose(file_find_handle);

你可能感兴趣的:(遍历目录文件)