void FileToString(std::string filename, std::string& string)
{
std::ifstream file;
file.open(filename.c_str(), std::ios::binary | std::ios::ate);
if (!file.is_open())
{
throw std::exception("Unable to read from file");
}
long lBufferSize = file.tellg();
file.seekg(0, std::ios::beg);
string.resize(lBufferSize +1);
file.read(&string[0], lBufferSize);
file.close();
}
No comments:
Post a Comment