WEB开发网
开发学院WEB开发ASP.NET 将dataset以xml形式发给客户端下载 阅读

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

 2005-07-02 17:01:39 来源:WEB开发网   
核心提示:Send DataSet as xml file.// Create MemeoryStreamSystem.IO.MemoryStream ms = new System.IO.MemoryStream();// Write MemeoryStreamMyDataset.WriteXml(ms,System.Data

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();

}

Tags:dataset xml 形式

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接