网站首页 文章专栏 文件操作.md
string file_id;
m_file_name = "/home/wenfengwang/same.jpg";
fstream infile;
infile.open(m_file_name, ios::in | ios::binary);
if(!infile.is_open()) {
DEBUG_LOG("not open");
}
infile.seekg (0, ios::end);
int file_size = infile.tellg();
DEBUG_LOG("file size is %d", file_size);
m_file_content.resize(file_size);
infile.seekg(0, ios::beg);
infile.read(const_cast<char*>(m_file_content.data()), file_size);
infile.close();