how to downloas xml file

E

Emmanuel Kahn

Hi Sreejumon and thanks

I would like to download xml and the user must select the path of the
downloaded file
the user will select where the file will be saved !!!

two problems:

1)I know that I can create a XML file on my server using writexml method
of the dataset.
To download the file I use simple HREF or asp hyperlink
for .doc file for instance it will automatically open a dialog box
asking the user open/save and where to save this file.
for xml the browser automatically open the file. when I want to save it
only and not to open it.

2) with rendercontrol how can the user select the path ?

thanks

Manu
 
K

Ken Cox [Microsoft MVP]

Hi Emmanuel,

The code below gets a dataset and pushes it out as a file for download. Does it
do what you need?

Ken
MVP [ASP.NET]


Imports System.io
Public Class writexmlp
Inherits System.Web.UI.Page


Private Sub Button1_Click _
(ByVal sender As System.Object, _
ByVal e As System.EventArgs) _
Handles Button1.Click
Dim ds As New DataSet
ds.ReadXml(Server.MapPath("a.xml"))
Dim xmlstream As New MemoryStream
ds.WriteXml(xmlstream)
Response.AppendHeader _
("Content-disposition", _
"attachment; filename=a.xml")
Response.ContentType = "application/download"
Response.BinaryWrite(xmlstream.ToArray())
Response.End()
End Sub
End Class



Hi Sreejumon and thanks

I would like to download xml and the user must select the path of the
downloaded file
the user will select where the file will be saved !!!

two problems:

1)I know that I can create a XML file on my server using writexml method
of the dataset.
To download the file I use simple HREF or asp hyperlink
for .doc file for instance it will automatically open a dialog box
asking the user open/save and where to save this file.
for xml the browser automatically open the file. when I want to save it
only and not to open it.

2) with rendercontrol how can the user select the path ?

thanks

Manu
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top