·您现在的位置: 云翼网络 >> 文章中心 >> 网站建设 >> 网站建设开发 >> ASP.NET网站开发 >> 将dataset以xml形式发给客户端下载
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();
}