2 Replies - 8377 Views - Last Post: 25 August 2012 - 01:10 PM

#1 triplesowcow  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 21
  • Joined: 31-August 11

XmlTextWriter incorrect constructor

Posted 23 August 2012 - 12:40 AM

I am doing a test project to learn how to save user inputted information. I am attempting to use the XmlTextWriter class in System::Xml, on msdn http://msdn.microsof...l.xmltextwriter it lists a constructor as XmlTextWriter(Stream, encoding), when I attempt to use that constructor i get this error:

Form1.h(130): error C2664: 'System::Xml::XmlTextWriter::XmlTextWriter(System::IO::TextWriter ^)' : cannot convert parameter 1 from 'System::Xml::XmlTextWriter ^' to 'System::IO::TextWriter ^'

the code for the load settings button is directly from the example on msdn, it looks like
                 Stream^ myStream;
				 SaveFileDialog^ saveFileDialog1 = gcnew SaveFileDialog;
				 saveFileDialog1->Filter = "txt files (*.txt)|*.txt|All files (*.*)|*.*|XML file (*.xml)|*.xml";
				 saveFileDialog1->FilterIndex = 3;
				 saveFileDialog1->RestoreDirectory = true;
				 if ( saveFileDialog1->ShowDialog() == System::Windows::Forms::DialogResult::OK )
					{
						if ( (myStream = saveFileDialog1->OpenFile()) != nullptr )
							 {
								UnicodeEncoding^ uniEncode = gcnew UnicodeEncoding();
								XmlTextWriter myWriter = gcnew XmlTextWriter(myStream , uniEncode);
								// Code to write the stream goes here.
								myStream->Close();
							 }
					}


I haven't made the xml writer actually do anything as I can't get past this error. It thinks I'm giving it an XmlTextWriter but I'm not. Any help is appreciated, thanks.

Is This A Good Question/Topic? 0
  • +

Replies To: XmlTextWriter incorrect constructor

#2 snoopy11  Icon User is offline

  • Engineering ● Software
  • member icon

Reputation: 810
  • View blog
  • Posts: 2,405
  • Joined: 20-March 10

Re: XmlTextWriter incorrect constructor

Posted 23 August 2012 - 10:12 PM

Hi,

You forgot the ^

You wrote

XmlTextWriter myWriter = gcnew XmlTextWriter(myStream , uniEncode);

should be

XmlTextWriter^ myWriter = gcnew XmlTextWriter(myStream , uniEncode);

Best Wishes

Snoopy.
Was This Post Helpful? 1
  • +
  • -

#3 triplesowcow  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 21
  • Joined: 31-August 11

Re: XmlTextWriter incorrect constructor

Posted 25 August 2012 - 01:10 PM

View Postsnoopy11, on 23 August 2012 - 10:12 PM, said:

Hi,

You forgot the ^

You wrote

XmlTextWriter myWriter = gcnew XmlTextWriter(myStream , uniEncode);

should be

XmlTextWriter^ myWriter = gcnew XmlTextWriter(myStream , uniEncode);

Best Wishes

Snoopy.


Thank you.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1