title: How can I convert an XElement to a byte array for a PutFile operation?
body: <p>I need to convert a big <code>XElement</code> to a byte array so that it can be uploaded later to a fileshare.  What is the correct method to call to do that?</p>
  <p>Below you see the signature of a method <code>fileShare.PutFile</code> that is internal:</p>
  <pre><code>void PutFile(string folder, string fileName, byte[] content);
  </code></pre>
  <p>Then given an <code>XElement xml</code>, I tried converting it to a byte array by encoding its <code>XElement.Value</code> using <code>Encoding.Default.GetBytes()</code> as follows:</p>
  <pre><code>byte[] bytes = Encoding.Default.GetBytes(xml.Value);
  fileShare.PutFile(folderName, blobName, bytes);
  </code></pre>
  <p>I am not so sure xml.Value (XElement.Value) is really what GetBytes method is really needing though.  Is this correct?</p>
  <p>To test this, I spun up a console app and put in some fake data.  I did this for the XElement:</p>
  <pre><code>XElement root = new XElement(&quot;Root&quot;,
              new XElement(&quot;Child1&quot;, 1),
              new XElement(&quot;Child2&quot;, 2),
              new XElement(&quot;Child3&quot;, 3),
              new XElement(&quot;Child4&quot;, 4),
              new XElement(&quot;Child5&quot;, 5),
              new XElement(&quot;Child6&quot;, 6)
          );
  </code></pre>
  <p>Then I tried that line of code putting to a byte array</p>
  <pre><code>byte[] bytes = Encoding.Default.GetBytes(root.Value);
  </code></pre>
  <p>Well I guess I forgot that when I step over and see Autos that  bytes variable is  btye[6]  and when I expand - I see that [0] = 49  and so on</p>
  <p>Now this may not mean it is not working ... or does it mean that?  How can I interpret the contents of the <code>bytes</code> array, to check whether it is correct?</p>