how to delete the last line of the text file using c#.

i applicaiton create a text file ..with 2 empty lines at the end of the File

now i just require a method which open the text file and delete the last 2 lines of the text File ..the code in c# is preferred

yaar please help me out with this on ..

thanks in advance

Do Something like this.. you can convert your code to C# easily

Public Shared Function ReadBillFile(ByVal Filename As String) As String
            Dim sr As StreamReader
            Dim i, linecount As Integer

            sr = File.OpenText(Filename)
            Dim contents As ArrayList
            Dim finalfile As String
            While Not (sr.EndOfStream)
                linecount += 1
                contents(linecount) += sr.ReadLine
            End While

            For i = 1 To contents.Count - 1
                finalfile += contents(i)
           Return finalfile 

        Catch ex As IOException
        End Try
    End Function

Note : After that, Edit the existing file and save the finalfile data in it.

Mark as sovled, if it helps you