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

类别:.NET开发 点击:0 评论:0 推荐:
 

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

    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

本文地址:http://com.8s8s.com/it/it43881.htm