#include <iostream>
#include <fstream>
#include <sstream>std::stringstream ss;
std::ifstream fileStream{ filePath, std::ios::binary };
std::stringstream ss;
ss << fileStream.rdbuf();
auto data = ss.str();
原文:https://www.cnblogs.com/ives/p/14872082.html