vb.net remove first line in a text file

I have a text file:


john mike      bob       larry
sue     linda    sherry    julie     bobby   mary             cassi

I remove the spaces and replace with commas per code below (Thanks Paul).  I also need to remove the gibbersh on the first line and the 2nd blank line.
Who is Participating?
Mike TomlinsonConnect With a Mentor Middle School Assistant TeacherCommented:
Haven't tested it yet but something like this should work:
Imports System.IO
Public Class Form1
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim sourceFile As String = "c:\someFile.txt"
        Dim tempFile As String = My.Computer.FileSystem.GetTempFileName
        Dim sr As New StreamReader(sourceFile)
        Dim sw As New StreamWriter(tempFile)
        Dim line As String = sr.ReadLine
        While Not IsNothing(line)
            If Not line.StartsWith("*****") Then
            End If
            line = sr.ReadLine
        End While
        My.Computer.FileSystem.RenameFile(tempFile, sourceFile)
    End Sub
End Class

Open in new window

bergertimeAuthor Commented:
I need to amend my question.  I need to remove every line that starts with *****
Mike TomlinsonMiddle School Assistant TeacherCommented:
What version VB.Net?

...and do you want to:
(1) Copy the file into memory.  Modify the contents in memory.  Replace the entire original file with the new contents.
(2) Use a secondary file.  Read original file line by line.  Write the desired lines to the secondary file.  Delete the original file.  Rename the secondary to the original files name.
bergertimeAuthor Commented:
2005, how bout option 2
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.