在它仍在更新时逐行读取txt

时间:2017-08-21 21:00:45

标签: .net vb.net

所以基本上我有一个DLL正在更新一个txt文件,每秒都有一行,我想编写一个vb.net表单,逐行读取它,但它仍然每秒更新但没有任何重复,然后把它在列表框中。

我试图制作一个 Do Until x Is Nothing 循环,但它不起作用。如果有人可以帮助我,请做。

最重要的是在任何情况下都不要重复

谢谢,如果我遗失了什么或者我的问题不好请在评论中告诉我,我会编辑它!

编辑:我尝试了什么:

Try
        Dim streamreader As StreamReader = My.Computer.FileSystem.OpenTextFileReader("C:\ex.txt")
        Dim line As String
        Dim linecount As Integer = 0

        Do
            line = streamreader.ReadLine + linecount

            linecount += 1

            Dim words As String() = line.Split(New String() {":"}, StringSplitOptions.None)

            ListView1.Items.Clear()
            Dim column1 As String = words(1)
            Dim column2 As String = words(2)
            Dim column3 As String = words(3)

            Dim lvi As New ListViewItem
            lvi.Text = column1
            lvi.SubItems.Add(column2)
            lvi.SubItems.Add(column3)
            ListView1.Items.Add(lvi)

        Loop Until line Is Nothing

        streamreader.Close()

    Catch ex As Exception
    End Try

^这是一个计时器

0 个答案:

没有答案