关于c++文件读写的小疑点

【求助】关于c++文件读写的小问题
自己在用c++语言写一个小程序,需要从dataGridView中读取表格数据然后存到一个文件里。我遇到的问题是程序通过编译,写入文件的代码也已经运行(我通过一个messageBox 确认)但是没有看到写出的文件,也没有异常。
以下是我的代码:希望高手指导一下。不胜感激!
private: System::Void button1_Click(System::Object^  sender, System::EventArgs^  e) {
 struct Select st;
 class map_Storage set;
 System::Object^ dkey1;Object^ dname1;Object^ dprice1;
String^ dkey;String^ dname;String^ dprice;
std::fstream ofile("111.txt");
                       // std::fstream ofile("D:\project\Ms 2010 PJ\yycl\111.txt",std::ios::binary);两个方式都用了。
 for(int i=0;i<=max;i++) //从object转化成String
 {   
 
 dkey1 = this->dataGridView1->Rows[i]->Cells[0]->Value;
 dkey = String::Format("{0}",dkey1);
 dname1 = this->dataGridView1->Rows[i]->Cells[1]->Value;
 dname=String::Format("{0}",dname1);
 dprice1 = this->dataGridView1->Rows[i]->Cells[2]->Value;
 dprice=String::Format("{0}",dprice);
 st = set.storageStructSelect(dkey,dname,dprice);
  ofile.write(reinterpret_cast<char*>(&st),sizeof st);//这里是问题关键是否有错误,我是从别的书上看到这个方法的。
 
 MessageBox::Show("111");//确认代码执行
 
 }

 ofile.close();
 }
这个是我的storageStructSelect方法:
struct Select map_Storage::storageStructSelect(System::String^ key,System::String^ name,System::String^ price)//自己写的方法,讲String转化成string
{
struct Select st;
std::string key1,name1,price1;
MarshalString(key,key1);//用的是微软社区里的转化方法,用指针做形参直接以字符串为中介转换的。
MarshalString(name,name1);
MarshalString(price,price1);
st.name=name1;st.key=key1;st.price=price1;
return st;
}
------解决方案--------------------
在每句ofile.wirie(...后面加
ofile.flush();