• 软件测试技术
  • 软件测试博客
  • 软件测试视频
  • 开源软件测试技术
  • 软件测试论坛
  • 软件测试沙龙
  • 软件测试资料下载
  • 软件测试杂志
  • 软件测试人才招聘
    暂时没有公告

字号: 小 中 大 | 推荐给好友 上一篇 | 下一篇

把dataset作为一个xml文件传给客户端

发布: 2007-6-30 18:56 | 作者: admin | 来源: | 查看: 17次 | 进入软件测试论坛讨论

领测软件测试网  

把它直接放在内存中,然后传给客户端

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

// 写dataset到MemeoryStream

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

 

// 写dataset到MemeoryStream

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

 

 

Response.Clear();

// 下载附件的名字

// 下载附件的名字

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

// 下载附件的大小,以便让浏览器显示进度条

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

// 下载附件的大小,以便让浏览器显示进度条

// 下载附件的大小,以便让浏览器显示进度条

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

// 指定浏览器为下载模式

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

// 指定浏览器为下载模式

// 指定浏览器为下载模式

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

// 发送到客户端

"application/octet-stream";

// 发送到客户端

// 发送到客户端

byte[] b = ms.ToArray();

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

Response.End();

}

byte[] b = ms.ToArray();

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

Response.End();

}

Response.End();

}

文章来源于领测软件测试网 https://www.ltesting.net/