title: XmlWriter throws exeception by XmlWriter.WriteAttributeString (SetAttribute token -> invalid XML Doc)
body: <p>I try to create a XML file</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;ebooks count="494"&gt;
  .....
  &lt;ebook absolute_path="J:\eBooks\Apress - Pro ASP.NET 4 in VB 2010, Third Edition.Sep.2010.ENG.pdf"&gt;
      &lt;file&gt;Apress - Pro ASP.NET 4 in VB 2010, Third Edition.Sep.2010.ENG.pdf&lt;/file&gt;
      &lt;size bytes="40176052"&gt;40Mb&lt;/size&gt;
      &lt;created datetime="25.12.2010 12:48:52"&gt;25.12.2010&lt;/created&gt;
      &lt;location&gt;J:\eBooks&lt;/location&gt;
  &lt;/ebook&gt;
  &lt;ebook absolute_path="J:\eBooks\Apress - Pro PHP and jQuery.Jun.2010.pdf"&gt;
      &lt;file&gt;Apress - Pro PHP and jQuery.Jun.2010.pdf&lt;/file&gt;
      &lt;size bytes="12523132"&gt;12.5Mb&lt;/size&gt;
      &lt;created datetime="10.07.2010 19:43:10"&gt;10.07.2010&lt;/created&gt;
      &lt;location&gt;J:\eBooks&lt;/location&gt;
    &lt;/ebook&gt;
  .....
  &lt;/ebooks&gt;
  </code></pre>
  
  <p>I wrote following VB.NET code to achieve that output, but I always get an exception about SetAttribute Token and unvalid XML document.</p>
  
  <pre><code>Dim xmlFileName As String = "J:\eBooks\report_" &amp; DateAndTime.Now.ToShortDateString &amp; ".xml"
  Dim xmlSetting As XmlWriterSettings = New XmlWriterSettings()
  xmlSetting.Indent = True
  Dim xw As XmlWriter = XmlWriter.Create(xmlFileName, xmlSetting)
  ...
  ...
  dim singleFile as String
  Dim myPdfFiles() as String = Directory.GetFiles(&lt;path_to_dir&gt;, &lt;pdf_files&gt;, SearchOption.AllDirectories)
  Try
      xw.WriteStartDocument()
      xw.WriteStartElement("ebooks")
      xw.WriteAttributeString("count", myPdfFiles.Count.ToString)
      For Each singleFile In myPdfFiles
          Dim fi As New FileInfo(singleFile)
          With xw
              .WriteStartElement("ebook")
              .WriteAttributeString("absolute_path", fi.FullName.ToString)
              .WriteElementString("file", fi.Name.ToString)
              .WriteElementString("size", Math.Round(fi.Length / 1048576, 2) &amp; "Mb")
              'Attribute BYTES for &lt;size&gt;....'
              .WriteAttributeString("bytes", fi.Length.ToString) '&lt;- EXCEPTION!!!!'
              .WriteElementString("created", fi.CreationTime.ToShortDateString)
              'xw.WriteAttributeString("datetime", fi.CreationTime) &lt;- would throw exception too'
              .WriteElementString("location", fi.DirectoryName)
              .WriteEndElement() '...close &lt;ebook&gt; element'
          End With
       Next
       xw.WriteEndElement() '..close &lt;ebooks&gt; element'
       xw.WriteEndDocument()
       xw.Flush()
       xw.Close()
  Catch ex As Exception
      MsgBox("Message : " &amp; ex.Message)
  End Try
  </code></pre>
  
  <p>Any Ideas why I get an exception? How do I get the XML-output as above ?</p>