Mega Code Archive

 
Categories / C# / XML
 

XmlReader ReadElementContentAsBinHex reads the element and decodes the BinHex content

using System; using System.IO; using System.Xml; public class Sample  {   public static void Main(){           byte[] buffer = new byte[1000];           int readBytes = 0;                    using (XmlReader reader = XmlReader.Create("output.xml")) {                                       FileStream outputFile = new FileStream(@"C:\newImage.jpg", FileMode.OpenOrCreate, FileAccess.Write, FileShare.Write);                 reader.ReadToFollowing("image");                 BinaryWriter bw = new BinaryWriter(outputFile);                 while ((readBytes = reader.ReadElementContentAsBinHex(buffer, 0, 50))>0) {                     bw.Write(buffer, 0, readBytes);                 }                 outputFile.Close();                        }    } }