Задание кодировки XML-файла при записи на диск - Visual Basic .NET
Формулировка задачи:
Подскажите, как при записи объекта DataSet на диск при помощи метода DataSet.WriteXml задать кодировку данных в XML-файле, например Win1251?
Решение задачи: «Задание кодировки XML-файла при записи на диск»
textual
Листинг программы
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 = "XmlDoc.xml" ' Create the FileStream to write with. Dim stream As New System.IO.FileStream _ (filename, System.IO.FileMode.Create) ' Create an XmlTextWriter with the fileStream. Dim xmlWriter As New System.Xml.XmlTextWriter _ (stream, System.Text.Encoding.Unicode) ' Write to the file with the WriteXml method. thisDataSet.WriteXml(xmlWriter) xmlWriter.Close() End Sub