我用dataset打开了一个xml文件,我修改了dataset中的内容后,想把它保存到xml文件中去,应该如何做?谢谢了

解决方案 »

  1.   

    Private Sub WriteXmlToFile(thisDataSet As DataSet)
        If thisDataSet Is Nothing Then
            Return
        End If
        ' Create a file name to write to.
        Dim filename As String = "myXmlDoc.xml"
        ' Create the FileStream to write with.
        Dim myFileStream As New System.IO.FileStream _
           (filename, System.IO.FileMode.Create)
        ' Create an XmlTextWriter with the fileStream.
        Dim myXmlWriter As New System.Xml.XmlTextWriter _
           (myFileStream, System.Text.Encoding.Unicode)
        ' Write to the file with the WriteXml method.
        thisDataSet.WriteXml(myXmlWriter)
        myXmlWriter.Close()
    End Sub