VB Code:
  1. Try
  2.             Dim loXmlWriter As New Xml.XmlTextWriter("\\My Documents\\mcsd.fclib", System.Text.Encoding.UTF8)
  3.  
  4.             loXmlWriter.WriteStartDocument()
  5.             loXmlWriter.WriteStartElement("testlib")
  6.  
  7.             loXmlWriter.WriteStartElement("info")
  8.             loXmlWriter.WriteAttributeString("name", "MCSD 70-306")
  9.             loXmlWriter.WriteEndElement()
  10.  
  11.             loXmlWriter.WriteStartElement("questioncollection")
  12.             loXmlWriter.WriteStartElement("question")
  13.             loXmlWriter.WriteAttributeString("qtext", "What is the latest version of windows")
  14.             loXmlWriter.WriteAttributeString("atext", "Windows XP")
  15.             loXmlWriter.WriteEndElement()
  16.             loXmlWriter.WriteEndElement()
  17.  
  18.             loXmlWriter.WriteEndElement()
  19.             loXmlWriter.WriteEndDocument()
  20.             loXmlWriter.Close()
  21.         Catch ex As Exception
  22.             MsgBox(ex.Message)
  23.         End Try

Hello all.

The above code throws an exception in the .NET framework when on the first line where it tries to write the file. What am i doing wrong, it can't be to compilcated but i can't for the life of me work it out.

Can someone help?

Also, if there is a better way to do this, please post

Thanks