string to byte[] conversion using XmlWriter and XmlReader
<p>I have two methods XmlWriter and XmlReader.<br>
I have a byte[] called Thumbprint.  In the writer I convert it from a byte[] to a string and write it to my Xml file. This works.  I need to figure out how to read it back in from a string and convert it back to a byte[].<br>
Here is my code so far: </p>

<pre><code>public void WriteXml(XmlWriter writer)
        {

            writer.WriteStartElement("agent");           


            writer.WriteStartElement("thumbprint");
            var encoding = new UnicodeEncoding();    
            if (Thumbprint != null)
            {
                string base64 = System.Convert.ToBase64String(encoding.GetBytes(Thumbprint.ToString()));
                writer.WriteCData(base64);
            }
            else
            { 
                writer.WriteEndElement();
            }
        }

public void ReadXml(XmlReader reader)
        {
            if (reader.IsStartElement("agent"))
            {    
                //
                // Read past &lt;agent&gt;
                //
                reader.Read();

                while (true)
                {
                    if (reader.IsStartElement("thumbprint"))
                    {
                         byte[] toDecodeByte = System.Convert.FromBase64String(Thumbprint.ToString());
                         Thumbprint = toDecodeByte;   
                    }
                    else
                    {
                        //
                        // Read &lt;/agent&gt;
                        //
                        reader.MoveToContent();
                        reader.ReadEndElement();
                        break;
                    }
                }
            }
            else
            {
                throw new XmlException("Expected &lt;agent&gt; element was not present");
            }
        }
</code></pre>

<p>Xml Input: </p>

<pre><code>&lt;thumbprint&gt;
    &lt;![CDATA[UwB5AHMAdABlAG0ALgBCAHkAdABlAFsAXQA=]]&gt;
&lt;/thumbprint&gt;
</code></pre>