| |
7.31.1.Use different Encoding to create StreamReader: Default, Unicode, UTF8, UTF7 |
|
Imports System.Text
Imports System.IO
Public Class Tester
Public Shared Sub Main
Dim myFileStream As FileStream
Dim myStreamReader As StreamReader
Dim strRead 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.Open, FileAccess.Read)
myStreamReader = New StreamReader(myFileStream, StreamEncoding)
Console.WriteLine(myStreamReader.ReadToEnd)
myFileStream.Close()
myStreamReader.Close()
Catch EX As IOException
Console.WriteLine(EX.Message)
End Try
End Sub
End Class
|
|
|