Howdy, Stranger!

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


Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Delete a text from text file

amanuelamanuel Posts: 29Member
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



  • rlcrlc Posts: 448Member
    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.