using System; using System.IO; using System.Xml; public class Sample { public static void Main(string[] args) { XmlTextReader reader = null; try { int filenum = 0; reader = new XmlTextReader(args[0]); reader.WhitespaceHandling = WhitespaceHandling.None; // Read the file. Stop at the Base64 element. while (reader.Read()) { if ("data" == reader.Name && reader.GetAttribute("mimetype") == "application/x-microsoft.net.object.binary.base64") { //Assume we want to read one more element to get the "value" tag reader.Read(); filenum++; FileStream fs = new FileStream(args[0] + "." + filenum.ToString(), FileMode.Append, FileAccess.Write); BinaryWriter w = new BinaryWriter(fs); int base64len = 0; byte[] base64 = new byte[8192]; do { //This is slow and dumb but it works and I'm to lazy to fix base64len = reader.ReadBase64(base64, 0, 1024); for (int i=0; i < base64len; i++) w.Write(base64[i]); } while(reader.Name == "value"); Console.WriteLine("Writing to file: {0} ", (args[0] + "." + filenum.ToString())); w.Flush(); w.Close(); fs.Close(); } } } finally { if (reader != null) reader.Close(); } } }