std::ifstream,在debug正常,为什么在release下出错
bool UserManage::LoadUsrData() //读取文件
{
fs::path p(m_path /"User"/"UserData.bin");
if(!fs::exists(p))
{
return false;
}
else
{
try
{
std::locale::global(std::locale(""));
std::ifstream ifs(p.string().c_str(), std::ios::binary); //这里release时ifs是错误的???
if(ifs.good())
{
boost::archive::binary_iarchive ia(ifs);
ia >>m_Clientuser;
return true;
}
}
catch (std::bad_alloc& ex) {// 资源分配不足
std::cerr << ex.what() << '\n';
//AfxMessageBox(TEXT("资源分配不足"));
exit(1);
} catch (boost::archive::archive_exception& ex) {// 文件数据损坏,不能进行序列化
std::cerr << ex.what() << '\n';
//AfxMessageBox(TEXT("文件数据损坏"));
exit(2);
}
}
}