作者timmy5519 (suda)
看板Visual_Basic
标题[.NET] 使用System IO只能读取英文
时间Fri Jan 2 15:03:09 2009
我看了网路上的范例
测试时发现只能读取英文和数字
中文读取会变乱码,是不是读进来的中文还没编码完成
Imports System
Imports System.IO
Imports System.Collections
Module Module1
Sub Main()
Dim objReader As New StreamReader("c:\test.txt")
Dim sLine As String = ""
Dim arrText As New ArrayList()
Do
sLine = objReader.ReadLine()
If Not sLine Is Nothing Then
arrText.Add(sLine)
End If
Loop Until sLine Is Nothing
objReader.Close()
For Each sLine In arrText
Console.WriteLine(sLine)
Next
Console.ReadLine()
End Sub
End Module
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 59.104.147.165
1F:推 horngsh:老问题, 用Encoding.Default就行了 01/02 15:04
2F:→ timmy5519:那个..我不会改耶>"< 01/02 15:23
3F:→ timmy5519:哈我知道了 Dim objReader As New StreamReader_ 01/02 15:32
4F:→ timmy5519:("c:\text.txt", System.Text.Encoding.Default) 01/02 15:33
5F:→ MOONRAKER:got the magic word, 恭喜 01/03 12:57