본문 바로가기
카테고리 없음

파일 읽어와 특정줄 읽기

by 호야호잇 2018. 8. 3.

'파일 읽어와서 특정 줄 읽기

    Private Function OneLineRead(ByVal fs As FileStream, ByVal line As Integer) As String

        Dim str As String = ""

        Dim sr As New StreamReader(fs, System.Text.Encoding.Default)

        Dim i As Integer = 0

        sr.BaseStream.Seek(0, SeekOrigin.Begin)

        While (sr.Peek > -1 And i < line - 1)

            sr.ReadLine()

            i += 1

        End While

        str = sr.ReadLine

        sr.Close()

        Return str

    End Function