I’m making an application in Visual Basic 2010 that will allow me to easily create .dev web addresses for my XAMPP local hosted sites.
So far, I’ve managed to add to the necessary files, but not remove.
I need a way to remove all text between two markers in a txt file. For example:
120.0.0.1 localhost
120.0.0.1 alsolocalhost
##testsite.dev#start#
127.0.0.1 testsite.dev
##testsite.dev#stop#
##indevsite.dev#start#
127.0.0.1 indevsite.dev
##indevsite.dev#stop#
I want to remove all the text between the ##testsite.dev#start# and ##testsite.dev#stop# markers, as well as removing the markers themselves.
In my visual basic code this is what I have so far:
Sub removeText(ByVal siteName)
Dim fileName As String = "hosts.txt"
Dim startMark As String = "##" + siteName + "#start#"
Dim stopMark As String = "##" + siteName + "#stop#"
'Code for removing text...
End Sub
All I need now is to be able to remove the text I want, without touching any of the other text (this includes not messing with it’s formatting).
Read all, make a backup copy and then write line by line checking the current block status (inside/outside)