Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27554

VS 2010 delete lines from a text file

$
0
0
Hi All,
I want to delete specific lines after I've written them to the console. The code I am using is below and with the red is marked where I want to delete:
Code:

Imports System.IO

Public Class Form1
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        'FileOpen(1, "D:\sample.txt", OpenMode.Input)
        'FileClose(1)
        'Dim rowCount As Integer = 0
        'Dim lines As String() = IO.File.ReadAllLines("D:\sample.txt")
        'MessageBox.Show("The file had " & lines.Length & " lines.")
        'rowCount = lines.Length
        'MsgBox(rowCount)
        Dim path As String = "E:\work\sample.txt"
        Dim line As String = ""
        Dim check As Boolean = True
        Dim sr As StreamReader = New StreamReader(path)
        Do
            Do While sr.Peek() >= 0
                line = sr.ReadLine()
                If line = "" Then
                    check = False
                    Exit Do
                End If
                Dim str As String
                Dim strArr() As String
                Dim count As Integer
                str = line
                strArr = str.Split(";")
                For count = 0 To strArr.Length - 1
                    Console.WriteLine(strArr(count))
                    Delete those line here....
                Next
            Loop
        Loop Until check = False
        sr.Close()
    End Sub
End Class

Thanks in advance!!

Viewing all articles
Browse latest Browse all 27554

Trending Articles