| |
7.31.2.Use different Encoding to create StreamWriter: Default, Unicode, UTF8, UTF7 |
|
Imports System.Text
Imports System.IO
Public Class Tester
Public Shared Sub Main
Dim myFileStream As FileStream
Dim myStreamWriter As StreamWriter
Dim strWrite As String
Dim StreamEncoding As Encoding
Try
StreamEncoding = Encoding.Default
'StreamEncoding = Encoding.Unicode
'StreamEncoding = Encoding.UTF8
'StreamEncoding = Encoding.UTF7
myFileStream = New FileStream ("test.txt", FileMode.OpenOrCreate, FileAccess.Write)
myStreamWriter = New StreamWriter(myFileStream, StreamEncoding)
strWrite = "asdf"
myStreamWriter.Write(strWrite)
myStreamWriter.Close()
myFileStream.Close()
Catch EX As IOException
Console.WriteLine(EX.Message)
End Try
End Sub
End Class
|
|
|