std::ostringstream oss; boost::property_tree::ini_parser::write_ini(oss,my_ptree); std::string inifile_text = oss.str();
根据需要替换为wstring / wostringstream