Send DataSet as xml file.

// Create MemeoryStream
System.IO.MemoryStream ms = new System.IO.MemoryStream();

// Write MemeoryStream

MyDataset.WriteXml(ms,System.Data.XmlWriteMode.IgnoreSchema);

Response.Clear();

// filename & attachment

Response.AddHeader(
"Content-Disposition""attachment; filename=Acounts.xml");

// size of the file,to show process of downloading

Response.AddHeader(
"Content-Length", ms.Length.ToString());

// mode:download

Response.ContentType 
= "application/octet-stream";

// sending to client

byte[] b = ms.ToArray();

Response.OutputStream.Write(b,
0,b.Length);

Response.End();

}
posted on 2007-02-25 11:04  ipusr  阅读(242)  评论(0编辑  收藏  举报