I have created a file with
XmlDocument xmldoc = new XmlDocument();
Can I make this file as downloadable? without saving it?
You could do something like:
XmlDocument doc = new XmlDocument();
doc.LoadXml(@"<xml>myxml</xml>");
Response.Clear();
Response.AddHeader("Content-Disposition", "attachment;filename=MyXmlDocument.xml");
Response.AddHeader("Content-Length", doc.OuterXml.Length.ToString());
Response.ContentType = "application/octet-stream";
Response.Write(doc.OuterXml);
This is how:
xmldoc.Save(Response.OutputStream)
Don't forget to set response mime type and other relevant properties so client browser will understand it as a file download.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With