Re: [問題] Visual C++ 2008 openFileDialog 問題

看板C_and_CPP (C/C++)作者 (好人超)時間16年前 (2010/03/30 13:25), 編輯推噓1(101)
留言2則, 2人參與, 最新討論串2/2 (看更多)
※ 引述《poundshih (達達)》之銘言: : 遇到的問題: (題意請描述清楚) : 小弟目前使用VC++ 2008要寫一個讀txt的小程式 : 但是在以往BCB6 上的 fp=fopen(openFileDialog1->FileName.c_str(),"r")可以使用 : 但在VC++ 2008上一直找不到傳回字串指標的方式 : 也就是openFileDialog1->FileName.c_str() 不能使用 : 請問在VC++2008上 要如何傳回字串指標?? : Thanks : 程式跑出來的錯誤結果: : 錯誤 1 error C2228: '.c_str' 的左邊必須有類別/結構/等位 : 開發平台: (例: VC++ or gcc/g++ or Dev-C++, Windows or Linux) : Visual C++ 2008 express : 有問題的code: (請善用置底文標色功能) : 補充說明: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) { Stream ^myStream; if (openFileDialog1->ShowDialog() == System::Windows::Forms::DialogResult::OK ) { if ( (myStream = openFileDialog1->OpenFile()) != nullptr ) { StreamReader ^reader = gcnew StreamReader(myStream); String ^ str = reader->ReadToEnd(); textBox1->Text = str; myStream->Close(); } } } 完整專案檔:http://james545.myweb.hinet.net/clr_file.zip 參考資料:http://0rz.tw/h2Gng http://0rz.tw/w0ark -- 我為什麼要這麼認真... -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 140.117.171.46

03/30 13:45, , 1F
可以了 感謝james732 的解惑
03/30 13:45, 1F

03/30 13:51, , 2F
認真~小弟我工作不順利的時候就會更常到這裡打混....orz
03/30 13:51, 2F
文章代碼(AID): #1BiOisYx (C_and_CPP)
討論串 (同標題文章)
文章代碼(AID): #1BiOisYx (C_and_CPP)