作者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