Results 1 to 5 of 5

Thread: [RESOLVED] [2008] Change A Line In A Text File

Threaded View

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jul 2006
    Posts
    219

    Resolved [RESOLVED] [2008] Change A Line In A Text File

    One of the features of this app I am making requires that I do this.
    XML is not used and CANNOT be used.
    I need to find a line in a text file and remove it.
    The file has a structure like this:

    jjb:/dkfhs/fjds.udi
    jjb:/dkfhs/sjsk.udi
    jjb:/sjaok/susk.udi

    Say I want to remove a specified line of the text file so the result would make the text file look like this:

    jjb:/dkfhs/fjds.udi
    jjb:/sjaok/susk.udi

    How would I do it?

    I searched the forums and found this but it does not remove my specified line.

    Code:
     Dim lines As New List(Of String)
    
    
    
            'Read the entire file into a collection of lines.
    
            lines.AddRange(IO.File.ReadAllLines(Form1.Label7.Text))
    
    
    
            For i As Integer = 0 To lines.Count - 1
    
                If lines(i) = "jjb:/dkfhs/sjsk.udi" Then
                    lines.Insert(i + 1, "")
                End If
    
    
            Next
    
            'Write out the new file contents.
    
            IO.File.WriteAllLines(Form1.Label7.Text + "seplugins\vsh.txt", lines.ToArray())
    Please help, any of it is much appreciated
    Louix.
    Last edited by Louix; Apr 8th, 2008 at 01:00 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width