Decodes Base64 and returns the decoded binary bytes.
using System; using System.IO; using System.Xml; public class Sample { private const string filename = "binary.xml"; public static void Main() { XmlTextReader reader = null; try { reader = new XmlTextReader(filename); reader.WhitespaceHandling = WhitespaceHandling.None; while (reader.Read()) { if ("Base64" == reader.Name) break; } Console.WriteLine("Reading Base64... "); int base64len = 0; byte[] base64 = new byte[1000]; do { base64len = reader.ReadBase64(base64, 0, 50); for (int i=0; i < base64len; i++) Console.Write(base64[i]); } while (reader.Name == "Base64"); int binhexlen = 0; byte[] binhex = new byte[1000]; do { binhexlen = reader.ReadBinHex(binhex, 0, 50); for (int i=0; i < binhexlen; i++) Console.Write(binhex[i]); } while (reader.Name == "BinHex"); } finally { Console.WriteLine(); Console.WriteLine("Processing of the file {0} complete.", filename); if (reader != null) reader.Close(); } } }