我正在尝试使用 c++ Visual Studio 2010 中的 Windows 应用程序表单浏览文件。此代码给出以下错误。任何人都可以帮助解决问题
private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {
Stream^ myStream;
OpenFileDialog^ openFileDialog1 = gcnew OpenFileDialog;
openFileDialog1->InitialDirectory = "c:\\";
openFileDialog1->Filter = "txt files (*.txt)|*.txt|All files (*.*)|*.*";
openFileDialog1->FilterIndex = 2;
openFileDialog1->RestoreDirectory = true;
if ( openFileDialog1->ShowDialog() == System::Windows::Forms::DialogResult::OK )
{
if ( (myStream = openFileDialog1->OpenFile()) != nullptr )
{
// Insert code to read the stream here.
myStream->Close();
}
}
}
错误 1 错误 C2065:“流”:未声明的标识符 c:\users\
错误 2 错误 C2065:“myStream”:未声明的标识符
错误 3 错误 C2065:“myStream”:未声明的标识符
错误 4 错误 C2065:“myStream”:未声明的标识符
错误 5 错误 C2227: '->Close' 的左侧必须指向