Delete a text from text file

I wanted to delete a text from a text file how can I do this?

Dim fileName As String = "a:/sometext.txt"

Dim sr As StreamReader = New StreamReader(File.Open(fileName, FileMode.Open))
Dim singniture As String
singniture = sr.ReadLine



  • You would have to..

    1) open the file like you are.
    2) read it into a string(or some sort buffer)
    3) Make your changes
    4) Overwrite the existing file

    It is easly to read the whole into a string and manipulate with string functions. As long as the file is not absorbantly big, if it is just use a buffer and read out a block at a time. You can use the string 'indexof' and/or 'remove' functions to manipulate easily.

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


In this Discussion