Last post Apr 17, 2017 01:46 PM by Khuram.Shahzad
Apr 13, 2017 06:12 AM|anshu4590|LINK
I am doing some operation on xml file and saving it as below
here, xdoc is object of xmldocument. I want to store this xml in user defined path or it will must get downloaded if possible.
Thanks in advance :)
Apr 13, 2017 06:30 AM|PatriceSc|LINK
Web Forms or MVC? See for example
http://www.softwire.com/blog/2011/08/23/content-disposition-headers-in-net/ , this is the content-disposition:attachment header that allows to tell the browser to show a download dialog.
Saving directly could be done only on the server side drive (keep in mind that when writing your code you are in the very special case where the web server and the browser client side is the same device).
Apr 14, 2017 01:59 AM|Eric Du|LINK
According to your description, as far as I know, please try the following steps:
1. Create a new XmlDocumnet object.
2. Load xml content.
3. Save it to the specify folder.
XmlDocument doc = new XmlDocument();
//Save the document to a file.
Apr 17, 2017 08:17 AM|anshu4590|LINK
Thanks for replying.
This is what i m doing. But i want is that application should ask user address where user wants to store xml eg if we download image and there is a prompt on screen asking where to store image. Like this https://drive.google.com/open?id=0B1fG-BKfQK5mUnFPeFRuZzVEUFU
Apr 17, 2017 10:25 AM|Eric Du|LINK
Please try the following code, I make it and test it in IE, I could choose a file path in save as option.
protected void Button1_Click(object sender, EventArgs e)
String xml = "<foo>Hello, world!</foo>";
var bytes = Encoding.ASCII.GetBytes(xml); //Data to be downloaded
Response.ContentType = "text/xml";
Response.AddHeader("Content-Disposition", "attachment; filename=\"test.xml\"");
using (var stream = new MemoryStream(bytes))
Apr 17, 2017 01:24 PM|anshu4590|LINK
It is saving a file named test.xml on user defined path.
But when i opened test.xml file, I don't how my aspx page data content was in the xml file in it. It is kind of hilarious, i mean how could content in xml file is copied form content of aspx page.
Apr 17, 2017 01:46 PM|Khuram.Shahzad|LINK
Please check this link: