当前位置: 首页 > 图文教程 > 网络编程 > ASP.NET > 将dataset以xml形式发给客户端下载

ASP.NET
细细品味ASP.NET(一)
细细品味ASP.NET(二)
细细品味ASP.NET(三)
细细品味ASP.NET(四)
细细品味ASP.NET(五)
用asp.net和xml做的新闻更新系统(1)
用asp.net和xml做的新闻更新系统(2)
用asp.net和xml做的新闻更新系统(3)
十天学会ASP.net(1)
十天学会ASP.net(2)
十天学会ASP.net(3)
十天学会ASP.net(4)
十天学会ASP.net(5)
十天学会ASP.net(6)
十天学会ASP.net(7)
十天学会ASP.net(8)
十天学会ASP.net(9)
十天学会ASP.net(10)
ASP.NET创建XML Web服务全接触(1)
ASP.NET创建XML Web服务全接触(2)

ASP.NET 中的 将dataset以xml形式发给客户端下载


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-08-14   浏览: 239 ::
收藏到网摘: n/a

SendDataSetasxmlfile.

//CreateMemeoryStream
System.IO.MemoryStreamms=newSystem.IO.MemoryStream();

//WriteMemeoryStream

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

Response.Clear();

//filename&attachment

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

//sizeofthefile,toshowprocessofdownloading

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

//mode:download

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

//sendingtoclient

byte[]b=ms.ToArray();

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

Response.End();

}