Imports System.IO
Public Class Form1
Private Sub btnChangeEncoding_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnChangeEncoding.Click
'http://net-informations.com/q/faq/memory.html
'http://www.csharp411.com/c-convert-string-to-stream-and-stream-to-string/
Dim xml_encoding As String = "<?xml version=""1.0"" encoding=""iso-8859-1""?>"
Dim mem As MemoryStream = New MemoryStream
Dim osetdtexmlout As New StreamWriter(mem, System.Text.Encoding.Default)
Dim osetdtexmlin As New StreamReader(New MemoryStream(System.Text.Encoding.Default.GetBytes(xml_encoding)), System.Text.Encoding.Default)
For i As Integer = 1 To 43
osetdtexmlin.Read()
Next
osetdtexmlout.WriteLine("<?xml version=""1.0"" encoding=""ISO-8859-1""?>")
osetdtexmlout.Write(osetdtexmlin.ReadToEnd)
osetdtexmlout.Flush()
mem.Position = 0
Dim sr As New StreamReader(mem)
Dim str As String = sr.ReadToEnd
osetdtexmlout.Close()
osetdtexmlin.Close()
Dim p1 As String = ""
End Sub
End Class
' https://www.pcreview.co.uk/threads/streamreader-to-read-from-string.2245002/
' http://www.csharp411.com/c-convert-string-to-stream-and-stream-to-string/
' https://stackoverflow.com/questions/235156/redirect-net-streamwriter-output-to-a-string-variable
No hay comentarios.:
Publicar un comentario