Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using (Stream XmlPartStream = new MemoryStream())
- using (XmlTextWriter XmlPartWriter = new XmlTextWriter(XmlPartStream, Encoding.Unicode))
- {
- XDocument TheXInvoice = TheInvoice.XInvoice(dtInvoiceLines);
- XmlPartWriter.Formatting = Formatting.Indented;//xml output will be pretty-printed
- TheXInvoice.WriteTo(XmlPartWriter);//write to the MemoryStream
- XmlPartWriter.Flush();//finish writing to MemoryStream
- XmlPartStream.Seek(0, SeekOrigin.Begin);//rewind stream (Position=0 would also work)
- Attachment XmlPart = new Attachment(XmlPartStream, InvoiceXmlName, "application/xml");
- TheMail.Attachments.Add(XmlPart);
- XmlPartStream.Flush();//finish writing from MemoryStream to Attachment
- // BUG: no bytes in the Attachment
- XmlPartStream.Seek(0, SeekOrigin.Begin);//rewind stream (Position=0 would also work)
- byte[] ZippedXml = LempelZiv.GZip(XmlPartStream);
- // OK: Entire XML in the ZippedXml
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement