JDP 發表於 2007-12-25 14:32:07

VB.NET 讀取文字檔,並依分隔符號將每個欄位值放入陣列

一次讀取
Dim szAllFileData As String
Dim arr() As String
szAllFileData = My.Computer.FileSystem.ReadAllText("a.txt")
arr = szAllFileData.Split(",".ToCharArray())
Dim i As Object
For Each i In arr
    RichTextBox1.Text += i + " "
Next i
如果是分行讀取.. 那就改用SteamReader的方式讀
Dim fs As New FileStream(檔案路徑, FileMode.Open, FileAccess.Read)
Dim sr As New StreamReader(檔案路徑, System.Text.Encoding.GetEncoding("BIG5"))
Dim strLine As String
   Do
      strLine = sr.ReadLine
      txtContent.Text = txtContent.Text + strLine
   Loop Until strLine Is Nothing
頁: [1]
查看完整版本: VB.NET 讀取文字檔,並依分隔符號將每個欄位值放入陣列