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

ASP.NET
如何在命令行下编译一个asp.net项目
ADO 与ADO.NET
当VS.NET2003遇上VS.NET2005,WebService部署何去何从
昨日关注:逐步解说: 将Web Form网页国际化
在.NET下编写中文代码程序
防止同一个程序多次运行。 [VB.NET]
Visual C#设计多功能关机程序
什么是Web Service?
实现ListView控件的行间隔颜色的优化代码
失去信心?还是再度迷惘(二):Mono only is Mono,not .NET never
在Winform中发HTTP请求(调用WebService服务)
.NET中加密和解密的实现方法 3
notNET中加密和解密的实现方法
.NET中加密和解密的实现方法2
mshtml:javascript为HTML文件中的Select添加option
VS.NET解决方案的兼容问题
关于创建快捷方式的小结
使用 GDI+ 进行双缓冲绘图
如何用DataGrid实现根据日期判断是否显示New标志
昨日关注:C-omega vs ADO.net

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


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-08-14   浏览: 126 ::
收藏到网摘: 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();

}