将dataset以xml形式发给客户端下载

来源:互联网 发布:杨康的幸福生活 知乎 编辑:程序博客网 时间:2024/05/22 14:05
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 728x15, 创建于 08-4-23MSDN */google_ad_slot = "3624277373";google_ad_width = 728;google_ad_height = 15;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 160x600, 创建于 08-4-23MSDN */google_ad_slot = "4367022601";google_ad_width = 160;google_ad_height = 600;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
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();

}

<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 728x15, 创建于 08-4-23MSDN */google_ad_slot = "3624277373";google_ad_width = 728;google_ad_height = 15;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 160x600, 创建于 08-4-23MSDN */google_ad_slot = "4367022601";google_ad_width = 160;google_ad_height = 600;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
原创粉丝点击