Actualmente estoy intentando escribir datos (máquina cliente) en un archivo xml donde el usuario puede guardar. Sin embargo, quiero que los usuarios puedan decidir dónde quieren guardar este archivo xml escrito. ¿Hay algún control o código que pueda usar para permitir que los usuarios guarden el archivo?¿Cómo creo un archivo XML con ASP.NET y solicito su descarga?
Actualización:
¿esa es la manera correcta de hacerlo?
**HttpContext.Current.Response.Write(xw.ToStroing()); <<< ??????**
HttpContext.Current.Response.End();
actualización:
XmlWriterSettings settings = new XmlWriterSettings();
settings.Indent = true;
MemoryStream ms = new MemoryStream();
HttpContext.Current.Response.Clear();
HttpContext.Current.Response.ContentType = "text/xml";
HttpContext.Current.Response.AddHeader("Content-Disposition:", "attachment;filename=" + HttpUtility.UrlEncode(fileName));
using (StringWriter sw = new StringWriter())
{
using (XmlWriter xw = XmlWriter.Create(ms, settings))
{
xw.WriteStartDocument();
xw.WriteStartElement("Name");
xw.WriteStartElement("Application");
................
......................
HttpContext.Current.Response.Write(xw.ToStroing());
HttpContext.Current.Response.End();
estoy usando y tengo que actualizar mi pregunta, por favor ver y todavía no funcionan –
probar este lugar: 'usando (XmlWriter xw = XmlWriter.Create (Response.OutputStream))' y luego no hacer el ' HttpContext.Current.Response.Write() ' –
también, no estoy seguro si ha notado que' xw.ToStroing() 'está mal escrito –