[.NET] 使用System IO只能讀取英文

看板Visual_Basic作者 (suda)時間17年前 (2009/01/02 15:03), 編輯推噓1(104)
留言5則, 3人參與, 最新討論串1/1
我看了網路上的範例 測試時發現只能讀取英文和數字 中文讀取會變亂碼,是不是讀進來的中文還沒編碼完成 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

01/02 15:04, , 1F
老問題, 用Encoding.Default就行了
01/02 15:04, 1F

01/02 15:23, , 2F
那個..我不會改耶>"<
01/02 15:23, 2F

01/02 15:32, , 3F
哈我知道了 Dim objReader As New StreamReader_
01/02 15:32, 3F

01/02 15:33, , 4F
("c:\text.txt", System.Text.Encoding.Default)
01/02 15:33, 4F

01/03 12:57, , 5F
got the magic word, 恭喜
01/03 12:57, 5F
文章代碼(AID): #19NRmk6j (Visual_Basic)