저는 CSV 파일이 있으며 마지막 줄은 별도의 텍스트 상자에만 가져와야합니다..csv 파일의 마지막 줄 가져 오기
Imports System.IO
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
Private Sub btnConditions_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnConditions.Click
Using reader As New StreamReader("C:\temp\Apr12log.txt")
Dim line As String = reader.ReadLine()
Dim fields() As String = line.Split(",".ToCharArray())
Dim fileDate = CDate(fields(0))
Dim fileTime = fields(1)
Dim fileTemp = fields(2)
Dim fileHum = fields(3)
Dim fileWindSpeed = fields(4)
Dim fileWindGust = fields(5)
Dim fileWindBearing = fields(6)
While line IsNot Nothing
line = reader.ReadLine()
End While
txtDate.Text = CStr(fileDate)
End Using
End Sub
End Class
첫 번째 행만 입력합니다. 마지막 행만 가져 오는 방법을 모르겠습니다. txtfile
01/04/12,00:00,5.4,80,3.0,4.5,9.6,261,0.0,0.0,1025.0,1.0,16.8,43,4.0,3.8,5.4,0.0,0,0.0
한 번에 .csv 파일을 메모리에 읽을 수있을만큼 작습니까? 아니면 거대한 파일입니까? –
이 파일은 30 줄 정도의 작은 파일입니다. – yolad
C#에서는 [this] (http://stackoverflow.com/questions/11625595/read-last-line-of-text-file)가 찾고있는 내용에 대한 답변을 제공합니다. – shahkalpesh