private void WriteXmlToFile(DataSet thisDataSet) { if (thisDataSet == 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. thisDataSet.WriteXml(myXmlWriter); myXmlWriter.Close(); }.NET中将数据写如文本类型文件的首选就是XML了。
if (thisDataSet == 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.
thisDataSet.WriteXml(myXmlWriter);
myXmlWriter.Close();
}.NET中将数据写如文本类型文件的首选就是XML了。