如何在用DataSet.WriteXml()方法生成xml的时候让xml文件支持中文?
如题。
我用这个方法生成的xml文件里面的中文都是乱码了。
如何解决?
问题点数:30、回复次数:2Top
1 楼klxyz(小康)回复于 2002-04-04 10:50:57 得分 30
private void WriteXmlToFile(DataSet ds) {
if (ds == null) { return; }
// Create a file name to write to.
string filename = "myXmlDoc.xml";
// Create the FileStream to write with.
System.IO.FileStream myFileStream = new System.IO.FileStream
(filename, System.IO.FileMode.Create);
// Create an XmlTextWriter with the fileStream.
System.Xml.XmlTextWriter myXmlWriter =
new System.Xml.XmlTextWriter(myFileStream, System.Text.Encoding.Unicode);
// Write to the file with the WriteXml method.
ds.WriteXml(myXmlWriter);
myXmlWriter.Close();
}Top
2 楼redcaff_l(热的咖啡)回复于 2002-04-04 10:59:44 得分 0
解决了!Top




