Visual c++ VC++;iostream/savefiledialog错误

Visual c++ VC++;iostream/savefiledialog错误,visual-c++,c++-cli,iostream,savefiledialog,Visual C++,C++ Cli,Iostream,Savefiledialog,我在用电话 要合并,请在用户定义的目录中创建文本文件 以下是我的代码中相互冲突的部分: private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) { array<Image^> ^imageArray ; int CurrentImage=0; imageArray = gcnew array<

我在用电话 要合并,请在用户定义的目录中创建文本文件

以下是我的代码中相互冲突的部分:

private: System::Void button1_Click(System::Object^  sender, System::EventArgs^  e) {
             array<Image^> ^imageArray ;
             int CurrentImage=0;
             imageArray = gcnew array<Image^>(9);
             array<String^>^ names = {L"adc1.bmp" ,"adc2.bmp","adc3.bmp","adc4.bmp","adc5.bmp","adc6.bmp","adc7.bmp","adc8.bmp"};
             for(int i=0; i<8; i++)
             {
                 System::ComponentModel::ComponentResourceManager^ resources = (gcnew System::ComponentModel::ComponentResourceManager(Form1::typeid));
                 imageArray[i] =(cli::safe_cast<System::Drawing::Bitmap^>(resources->GetObject(names[i])));
             }

             if((this->comboBox4->Text == String::Empty)||(this->textBox2->Text == String::Empty)){
                 this->textBox1->Text="please select port and save file directory";

             }


             else{ // start assigning
                 try{ // first make sure port isn't busy/open
                     if(!this->serialPort1->IsOpen){
                         // select the port whose name is in comboBox4 (select port)
                         this->serialPort1->PortName=this->comboBox4->Text;
                         //open the port
                         this->serialPort1->Open();
                         // sending
                         String^ name_ = this->serialPort1->PortName;
                         String^ START; 
                         int m=0;
                         //send data to setup timer on the microcontroller
                         this->serialPort1->WriteLine(START);
                         Stream^ myStream;
                         SaveFileDialog^ saveFileDialog1 = gcnew SaveFileDialog;
                         saveFileDialog1->Filter = "txt files (*.txt)|*.txt|All files (*.*)|*.*";
                         saveFileDialog1->FilterIndex = 2;
                         saveFileDialog1->RestoreDirectory = true;
                         if ( saveFileDialog1->ShowDialog() == System::Windows::Forms::DialogResult::OK  )
                         {
                             if ( (myStream = saveFileDialog1->OpenFile()) != nullptr )
                             {
                                 // receiving
                                 myStream<<"ADC1;ADC2;ADC3;ADC4;ADC5;ADC6;ADC7;ADC8"<<endl;
                                 while(START){
                                     myStream<<this->serialPort1->ReadLine()<<";";
                                     pictureBox1->image=imagearray[m];
                                     m++;
                                     if(m==7){
                                         myStream<<endl;
                                         m=0;
                                     }
                                 }
                             }}}
                     else{
                         this->textBox1->Text="Warning: port is busy or isn't open";
                     }
                 }
                 catch(UnauthorizedAccessException^){
                     this->textBox1->Text="Unauthorized access";
                 }
             }

         }
private:System::Void按钮1\u单击(系统::对象^sender,系统::事件参数^e){
数组^imageArray;
int CurrentImage=0;
imageArray=gc新阵列(9);
数组^names={L“adc1.bmp”、“adc2.bmp”、“adc3.bmp”、“adc4.bmp”、“adc5.bmp”、“adc6.bmp”、“adc7.bmp”、“adc8.bmp”};
对于(int i=0;iGetObject(名称[i]);
}
if((this->comboBox4->Text==String::Empty)| |(this->textBox2->Text==String::Empty)){
此->textBox1->Text=“请选择端口并保存文件目录”;
}
else{//开始分配
请尝试{//首先确保端口不忙/未打开
如果(!this->serialPort1->IsOpen){
//选择名称在comboBox4中的端口(选择端口)
this->serialPort1->PortName=this->comboBox4->Text;
//开埠
此->串行端口1->打开();
//发送
字符串^name=此->串行端口1->端口名;
字符串^START;
int m=0;
//向微控制器上的设置定时器发送数据
此->串行端口1->写入线(开始);
流^ myStream;
SaveFileDialog^saveFileDialog1=gcnew SaveFileDialog;
saveFileDialog1->Filter=“txt文件(*.txt)|*.txt |所有文件(*.*)|*.”;
saveFileDialog1->FilterIndex=2;
saveFileDialog1->RestoreDirectory=true;
如果(saveFileDialog1->ShowDialog()==System::Windows::Forms::DialogResult::OK)
{
如果((myStream=saveFileDialog1->OpenFile())!=nullptr)
{
//接收

myStreamSystem::IO::Stream不支持操作符>如std:[i | o | IO]流。若要写入System::IO::Stream,请使用Stream::write方法

查看System::IO::Stream的文档:


不能将托管流类与非托管

    1>------ Build started: Project: Data_Logger, Configuration: Debug Win32 ------
1>  Data_Logger.cpp
1>c:\documents and settings\310098394\desktop\programming\visual c++\data_logger\data_logger\Form1.h(301): error C2784: 'std::basic_ostream<_Elem,_Traits> &std::operator <<(std::basic_ostream<_Elem,_Traits> &,const std::error_code &)' : could not deduce template argument for 'std::basic_ostream<_Elem,_Traits> &' from 'System::IO::Stream ^'
1>          C:\Program Files\Microsoft Visual Studio 10.0\VC\include\ostream(1085) : see declaration of 'std::operator <<'
1>c:\documents and settings\310098394\desktop\programming\visual c++\data_logger\data_logger\Form1.h(301): error C2784: 'std::basic_ostream<_Elem,_Traits> &std::operator <<(std::basic_ostream<_Elem,_Traits> &&,_Ty)' : could not deduce template argument for 'std::basic_ostream<_Elem,_Traits> &&' from 'System::IO::Stream ^'
1>          C:\Program Files\Microsoft Visual Studio 10.0\VC\include\ostream(968) : see declaration of 'std::operator <<'
1>c:\documents and settings\310098394\desktop\programming\visual c++\data_logger\data_logger\Form1.h(301): error C2784: 'std::basic_ostream<char,_Traits> &std::operator <<(std::basic_ostream<char,_Traits> &,unsigned char)' : could not deduce template argument for 'std::basic_ostream<char,_Traits> &' from 'System::IO::Stream ^'
1>          C:\Program Files\Microsoft Visual Studio 10.0\VC\include\ostream(958) : see declaration of 'std::operator <<'
1>c:\documents and settings\310098394\desktop\programming\visual c++\data_logger\data_logger\Form1.h(301): error C2784: 'std::basic_ostream<char,_Traits> &std::operator <<(std::basic_ostream<char,_Traits> &,const unsigned char *)' : could not deduce template argument for 'std::basic_ostream<char,_Traits> &' from 'System::IO::Stream ^'
1>          C:\Program Files\Microsoft Visual Studio 10.0\VC\include\ostream(951) : see declaration of 'std::operator <<'
1>c:\documents and settings\310098394\desktop\programming\visual c++\data_logger\data_logger\Form1.h(301): error C2784: 'std::basic_ostream<char,_Traits> &std::operator <<(std::basic_ostream<char,_Traits> &,signed char)' : could not deduce template argument for 'std::basic_ostream<char,_Traits> &' from 'System::IO::Stream ^'
1>          C:\Program Files\Microsoft Visual Studio 10.0\VC\include\ostream(944) : see declaration of 'std::operator <<'
1>c:\documents and settings\310098394\desktop\programming\visual c++\data_logger\data_logger\Form1.h(301): error C2784: 'std::basic_ostream<char,_Traits> &std::operator <<(std::basic_ostream<char,_Traits> &,const signed char *)' : could not deduce template argument for 'std::basic_ostream<char,_Traits> &' from 'System::IO::Stream ^'
1>          C:\Program Files\Microsoft Visual Studio 10.0\VC\include\ostream(937) : see declaration of 'std::operator <<'
1>c:\documents and settings\310098394\desktop\programming\visual c++\data_logger\data_logger\Form1.h(301): error C2784: 'std::basic_ostream<_Elem,_Traits> &std::operator <<(std::basic_ostream<_Elem,_Traits> &,_Elem)' : could not deduce template argument for 'std::basic_ostream<_Elem,_Traits> &' from 'System::IO::Stream ^'
1>          C:\Program Files\Microsoft Visual Studio 10.0\VC\include\ostream(898) : see declaration of 'std::operator <<'
1>c:\documents and settings\310098394\desktop\programming\visual c++\data_logger\data_logger\Form1.h(301): error C2784: 'std::basic_ostream<_Elem,_Traits> &std::operator <<(std::basic_ostream<_Elem,_Traits> &,const _Elem *)' : could not deduce template argument for 'std::basic_ostream<_Elem,_Traits> &' from 'System::IO::Stream ^'
1>          C:\Program Files\Microsoft Visual Studio 10.0\VC\include\ostream(851) : see declaration of 'std::operator <<'
1>c:\documents and settings\310098394\desktop\programming\visual c++\data_logger\data_logger\Form1.h(301): error C2784: 'std::basic_ostream<char,_Traits> &std::operator <<(std::basic_ostream<char,_Traits> &,char)' : could not deduce template argument for 'std::basic_ostream<char,_Traits> &' from 'System::IO::Stream ^'
1>          C:\Program Files\Microsoft Visual Studio 10.0\VC\include\ostream(811) : see declaration of 'std::operator <<'
1>c:\documents and settings\310098394\desktop\programming\visual c++\data_logger\data_logger\Form1.h(301): error C2784: 'std::basic_ostream<char,_Traits> &std::operator <<(std::basic_ostream<char,_Traits> &,const char *)' : could not deduce template argument for 'std::basic_ostream<char,_Traits> &' from 'System::IO::Stream ^'
1>          C:\Program Files\Microsoft Visual Studio 10.0\VC\include\ostream(764) : see declaration of 'std::operator <<'
1>c:\documents and settings\310098394\desktop\programming\visual c++\data_logger\data_logger\Form1.h(301): error C2784: 'std::basic_ostream<_Elem,_Traits> &std::operator <<(std::basic_ostream<_Elem,_Traits> &,char)' : could not deduce template argument for 'std::basic_ostream<_Elem,_Traits> &' from 'System::IO::Stream ^'
1>          C:\Program Files\Microsoft Visual Studio 10.0\VC\include\ostream(726) : see declaration of 'std::operator <<'
1>c:\documents and settings\310098394\desktop\programming\visual c++\data_logger\data_logger\Form1.h(301): error C2784: 'std::basic_ostream<_Elem,_Traits> &std::operator <<(std::basic_ostream<_Elem,_Traits> &,const char *)' : could not deduce template argument for 'std::basic_ostream<_Elem,_Traits> &' from 'System::IO::Stream ^'
1>          C:\Program Files\Microsoft Visual Studio 10.0\VC\include\ostream(679) : see declaration of 'std::operator <<'
1>c:\documents and settings\310098394\desktop\programming\visual c++\data_logger\data_logger\Form1.h(301): error C2676: binary '<<' : 'System::IO::Stream ^' does not define this operator or a conversion to a type acceptable to the predefined operator
1>c:\documents and settings\310098394\desktop\programming\visual c++\data_logger\data_logger\Form1.h(304): error C2784: 'std::basic_ostream<_Elem,_Traits> &std::operator <<(std::basic_ostream<_Elem,_Traits> &,const std::error_code &)' : could not deduce template argument for 'std::basic_ostream<_Elem,_Traits> &' from 'System::IO::Stream ^'
1>          C:\Program Files\Microsoft Visual Studio 10.0\VC\include\ostream(1085) : see declaration of 'std::operator <<'
1>c:\documents and settings\310098394\desktop\programming\visual c++\data_logger\data_logger\Form1.h(304): error C2784: 'std::basic_ostream<_Elem,_Traits> &std::operator <<(std::basic_ostream<_Elem,_Traits> &&,_Ty)' : could not deduce template argument for 'std::basic_ostream<_Elem,_Traits> &&' from 'System::IO::Stream ^'
1>          C:\Program Files\Microsoft Visual Studio 10.0\VC\include\ostream(968) : see declaration of 'std::operator <<'
1>c:\documents and settings\310098394\desktop\programming\visual c++\data_logger\data_logger\Form1.h(304): error C2784: 'std::basic_ostream<char,_Traits> &std::operator <<(std::basic_ostream<char,_Traits> &,unsigned char)' : could not deduce template argument for 'std::basic_ostream<char,_Traits> &' from 'System::IO::Stream ^'
1>          C:\Program Files\Microsoft Visual Studio 10.0\VC\include\ostream(958) : see declaration of 'std::operator <<'
1>c:\documents and settings\310098394\desktop\programming\visual c++\data_logger\data_logger\Form1.h(304): error C2784: 'std::basic_ostream<char,_Traits> &std::operator <<(std::basic_ostream<char,_Traits> &,const unsigned char *)' : could not deduce template argument for 'std::basic_ostream<char,_Traits> &' from 'System::IO::Stream ^'
1>          C:\Program Files\Microsoft Visual Studio 10.0\VC\include\ostream(951) : see declaration of 'std::operator <<'
1>c:\documents and settings\310098394\desktop\programming\visual c++\data_logger\data_logger\Form1.h(304): error C2784: 'std::basic_ostream<char,_Traits> &std::operator <<(std::basic_ostream<char,_Traits> &,signed char)' : could not deduce template argument for 'std::basic_ostream<char,_Traits> &' from 'System::IO::Stream ^'
1>          C:\Program Files\Microsoft Visual Studio 10.0\VC\include\ostream(944) : see declaration of 'std::operator <<'
1>c:\documents and settings\310098394\desktop\programming\visual c++\data_logger\data_logger\Form1.h(304): error C2784: 'std::basic_ostream<char,_Traits> &std::operator <<(std::basic_ostream<char,_Traits> &,const signed char *)' : could not deduce template argument for 'std::basic_ostream<char,_Traits> &' from 'System::IO::Stream ^'
1>          C:\Program Files\Microsoft Visual Studio 10.0\VC\include\ostream(937) : see declaration of 'std::operator <<'
1>c:\documents and settings\310098394\desktop\programming\visual c++\data_logger\data_logger\Form1.h(304): error C2784: 'std::basic_ostream<_Elem,_Traits> &std::operator <<(std::basic_ostream<_Elem,_Traits> &,_Elem)' : could not deduce template argument for 'std::basic_ostream<_Elem,_Traits> &' from 'System::IO::Stream ^'
1>          C:\Program Files\Microsoft Visual Studio 10.0\VC\include\ostream(898) : see declaration of 'std::operator <<'
1>c:\documents and settings\310098394\desktop\programming\visual c++\data_logger\data_logger\Form1.h(304): error C2784: 'std::basic_ostream<_Elem,_Traits> &std::operator <<(std::basic_ostream<_Elem,_Traits> &,const _Elem *)' : could not deduce template argument for 'std::basic_ostream<_Elem,_Traits> &' from 'System::IO::Stream ^'
1>          C:\Program Files\Microsoft Visual Studio 10.0\VC\include\ostream(851) : see declaration of 'std::operator <<'
1>c:\documents and settings\310098394\desktop\programming\visual c++\data_logger\data_logger\Form1.h(304): error C2784: 'std::basic_ostream<char,_Traits> &std::operator <<(std::basic_ostream<char,_Traits> &,char)' : could not deduce template argument for 'std::basic_ostream<char,_Traits> &' from 'System::IO::Stream ^'
1>          C:\Program Files\Microsoft Visual Studio 10.0\VC\include\ostream(811) : see declaration of 'std::operator <<'
1>c:\documents and settings\310098394\desktop\programming\visual c++\data_logger\data_logger\Form1.h(304): error C2784: 'std::basic_ostream<char,_Traits> &std::operator <<(std::basic_ostream<char,_Traits> &,const char *)' : could not deduce template argument for 'std::basic_ostream<char,_Traits> &' from 'System::IO::Stream ^'
1>          C:\Program Files\Microsoft Visual Studio 10.0\VC\include\ostream(764) : see declaration of 'std::operator <<'
1>c:\documents and settings\310098394\desktop\programming\visual c++\data_logger\data_logger\Form1.h(304): error C2784: 'std::basic_ostream<_Elem,_Traits> &std::operator <<(std::basic_ostream<_Elem,_Traits> &,char)' : could not deduce template argument for 'std::basic_ostream<_Elem,_Traits> &' from 'System::IO::Stream ^'
1>          C:\Program Files\Microsoft Visual Studio 10.0\VC\include\ostream(726) : see declaration of 'std::operator <<'
1>c:\documents and settings\310098394\desktop\programming\visual c++\data_logger\data_logger\Form1.h(304): error C2784: 'std::basic_ostream<_Elem,_Traits> &std::operator <<(std::basic_ostream<_Elem,_Traits> &,const char *)' : could not deduce template argument for 'std::basic_ostream<_Elem,_Traits> &' from 'System::IO::Stream ^'
1>          C:\Program Files\Microsoft Visual Studio 10.0\VC\include\ostream(679) : see declaration of 'std::operator <<'
1>c:\documents and settings\310098394\desktop\programming\visual c++\data_logger\data_logger\Form1.h(304): error C2676: binary '<<' : 'System::IO::Stream ^' does not define this operator or a conversion to a type acceptable to the predefined operator
1>c:\documents and settings\310098394\desktop\programming\visual c++\data_logger\data_logger\Form1.h(305): error C2039: 'image' : is not a member of 'System::Windows::Forms::PictureBox'
1>          c:\program files\reference assemblies\microsoft\framework\.netframework\v4.0\system.windows.forms.dll : see declaration of 'System::Windows::Forms::PictureBox'
1>c:\documents and settings\310098394\desktop\programming\visual c++\data_logger\data_logger\Form1.h(305): error C2065: 'imagearray' : undeclared identifier
1>c:\documents and settings\310098394\desktop\programming\visual c++\data_logger\data_logger\Form1.h(308): error C2784: 'std::basic_ostream<_Elem,_Traits> &std::operator <<(std::basic_ostream<_Elem,_Traits> &,const std::error_code &)' : could not deduce template argument for 'std::basic_ostream<_Elem,_Traits> &' from 'System::IO::Stream ^'
1>          C:\Program Files\Microsoft Visual Studio 10.0\VC\include\ostream(1085) : see declaration of 'std::operator <<'
1>c:\documents and settings\310098394\desktop\programming\visual c++\data_logger\data_logger\Form1.h(308): error C2784: 'std::basic_ostream<_Elem,_Traits> &std::operator <<(std::basic_ostream<_Elem,_Traits> &&,_Ty)' : could not deduce template argument for 'std::basic_ostream<_Elem,_Traits> &&' from 'System::IO::Stream ^'
1>          C:\Program Files\Microsoft Visual Studio 10.0\VC\include\ostream(968) : see declaration of 'std::operator <<'
1>c:\documents and settings\310098394\desktop\programming\visual c++\data_logger\data_logger\Form1.h(308): error C2784: 'std::basic_ostream<char,_Traits> &std::operator <<(std::basic_ostream<char,_Traits> &,unsigned char)' : could not deduce template argument for 'std::basic_ostream<char,_Traits> &' from 'System::IO::Stream ^'
1>          C:\Program Files\Microsoft Visual Studio 10.0\VC\include\ostream(958) : see declaration of 'std::operator <<'
1>c:\documents and settings\310098394\desktop\programming\visual c++\data_logger\data_logger\Form1.h(308): error C2784: 'std::basic_ostream<char,_Traits> &std::operator <<(std::basic_ostream<char,_Traits> &,const unsigned char *)' : could not deduce template argument for 'std::basic_ostream<char,_Traits> &' from 'System::IO::Stream ^'
1>          C:\Program Files\Microsoft Visual Studio 10.0\VC\include\ostream(951) : see declaration of 'std::operator <<'
1>c:\documents and settings\310098394\desktop\programming\visual c++\data_logger\data_logger\Form1.h(308): error C2784: 'std::basic_ostream<char,_Traits> &std::operator <<(std::basic_ostream<char,_Traits> &,signed char)' : could not deduce template argument for 'std::basic_ostream<char,_Traits> &' from 'System::IO::Stream ^'
1>          C:\Program Files\Microsoft Visual Studio 10.0\VC\include\ostream(944) : see declaration of 'std::operator <<'
1>c:\documents and settings\310098394\desktop\programming\visual c++\data_logger\data_logger\Form1.h(308): error C2784: 'std::basic_ostream<char,_Traits> &std::operator <<(std::basic_ostream<char,_Traits> &,const signed char *)' : could not deduce template argument for 'std::basic_ostream<char,_Traits> &' from 'System::IO::Stream ^'
1>          C:\Program Files\Microsoft Visual Studio 10.0\VC\include\ostream(937) : see declaration of 'std::operator <<'
1>c:\documents and settings\310098394\desktop\programming\visual c++\data_logger\data_logger\Form1.h(308): error C2784: 'std::basic_ostream<_Elem,_Traits> &std::operator <<(std::basic_ostream<_Elem,_Traits> &,_Elem)' : could not deduce template argument for 'std::basic_ostream<_Elem,_Traits> &' from 'System::IO::Stream ^'
1>          C:\Program Files\Microsoft Visual Studio 10.0\VC\include\ostream(898) : see declaration of 'std::operator <<'
1>c:\documents and settings\310098394\desktop\programming\visual c++\data_logger\data_logger\Form1.h(308): error C2784: 'std::basic_ostream<_Elem,_Traits> &std::operator <<(std::basic_ostream<_Elem,_Traits> &,const _Elem *)' : could not deduce template argument for 'std::basic_ostream<_Elem,_Traits> &' from 'System::IO::Stream ^'
1>          C:\Program Files\Microsoft Visual Studio 10.0\VC\include\ostream(851) : see declaration of 'std::operator <<'
1>c:\documents and settings\310098394\desktop\programming\visual c++\data_logger\data_logger\Form1.h(308): error C2784: 'std::basic_ostream<char,_Traits> &std::operator <<(std::basic_ostream<char,_Traits> &,char)' : could not deduce template argument for 'std::basic_ostream<char,_Traits> &' from 'System::IO::Stream ^'
1>          C:\Program Files\Microsoft Visual Studio 10.0\VC\include\ostream(811) : see declaration of 'std::operator <<'
1>c:\documents and settings\310098394\desktop\programming\visual c++\data_logger\data_logger\Form1.h(308): error C2784: 'std::basic_ostream<char,_Traits> &std::operator <<(std::basic_ostream<char,_Traits> &,const char *)' : could not deduce template argument for 'std::basic_ostream<char,_Traits> &' from 'System::IO::Stream ^'
1>          C:\Program Files\Microsoft Visual Studio 10.0\VC\include\ostream(764) : see declaration of 'std::operator <<'
1>c:\documents and settings\310098394\desktop\programming\visual c++\data_logger\data_logger\Form1.h(308): error C2784: 'std::basic_ostream<_Elem,_Traits> &std::operator <<(std::basic_ostream<_Elem,_Traits> &,char)' : could not deduce template argument for 'std::basic_ostream<_Elem,_Traits> &' from 'System::IO::Stream ^'
1>          C:\Program Files\Microsoft Visual Studio 10.0\VC\include\ostream(726) : see declaration of 'std::operator <<'
1>c:\documents and settings\310098394\desktop\programming\visual c++\data_logger\data_logger\Form1.h(308): error C2784: 'std::basic_ostream<_Elem,_Traits> &std::operator <<(std::basic_ostream<_Elem,_Traits> &,const char *)' : could not deduce template argument for 'std::basic_ostream<_Elem,_Traits> &' from 'System::IO::Stream ^'
1>          C:\Program Files\Microsoft Visual Studio 10.0\VC\include\ostream(679) : see declaration of 'std::operator <<'
1>c:\documents and settings\310098394\desktop\programming\visual c++\data_logger\data_logger\Form1.h(308): error C2676: binary '<<' : 'System::IO::Stream ^' does not define this operator or a conversion to a type acceptable to the predefined operator
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========