根据文本文件获得每行字符串的数组

80酷酷网    80kuku.com

  数组|字符串'根据文本文件获得每行字符串的数组

Function GetLineStrByTxtFile(ByVal txtFileName As String) As ArrayList

Dim fs As IO.FileStream = New IO.FileStream(txtFileName, IO.FileMode.Open, IO.FileAccess.Read)

Dim sr As IO.StreamReader = New IO.StreamReader(fs, System.Text.Encoding.GetEncoding("GB2312"))

Dim ArrayStr As Array = sr.ReadToEnd().Split(vbCrLf)

Dim i As Integer : Dim tmList As New ArrayList

For i = 0 To ArrayStr.Length - 1

tmList.Add(ArrayStr.GetValue(i))

Next

fs.Close() : Return tmList

End Function


分享到
  • 微信分享
  • 新浪微博
  • QQ好友
  • QQ空间
点击: