用DataSet的WriteXml方法把DataSet写入内存流时,缺少XML文档的声明行 (转)
用DataSet的WriteXml方法把DataSet写入内存流时,缺少XML文档的声明行
dataSet.WriteXml( memoryStream, XmlWriteMode.WriteSchema ), 写完后memoryStream中没有XML文档第一行的声明部分。
解决方法:在memoryStream里先写入声明行。
示例代码:
![](https://ibmfm.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://ibmfm.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://ibmfm.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://ibmfm.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://ibmfm.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://ibmfm.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://ibmfm.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://ibmfm.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://ibmfm.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://ibmfm.cnblogs.com/Images/OutliningIndicators/None.gif)
用DataSet的WriteXml方法把DataSet写入内存流时,缺少XML文档的声明行
dataSet.WriteXml( memoryStream, XmlWriteMode.WriteSchema ), 写完后memoryStream中没有XML文档第一行的声明部分。
解决方法:在memoryStream里先写入声明行。
示例代码: