在没有WriteXML()的情况下将DataSet转换为XML

时间:2011-05-14 16:25:43

标签: asp.net xml

我想将数据集转换为XML文件而不使用内置函数的WriteXML()。任何人都可以告诉我有没有其他选择?

private void WriteDataSetToXmlFile(DataSet ds, string fileName)
{
    if (ds != null)
    {
        string b = TextBox2.Text;

        string absoluteFileName = Server.MapPath(fileName);
        System.IO.FileStream myFileStream = new System.IO.FileStream("D:\\XMLCON\\XMLCON\\" +b.ToString() +".xml", System.IO.FileMode.Create);
        System.Xml.XmlTextWriter myXmlWriter = new System.Xml.XmlTextWriter(myFileStream, System.Text.Encoding.Unicode);
        ds.WriteXml(myXmlWriter);
        myXmlWriter.Close();

    }
}

0 个答案:

没有答案