Q:

Inserting text after specific tag

I have a text file comprised of different tags. I am able to find out if a specific tag exists within the document using the following...
Public Class Form1

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    Dim text As String = IO.File.ReadAllText("C:\Example.xtp")
    Dim index As Integer = text.IndexOf("<Tools>")
    If index >= 0 Then
        ' String is in file, starting at character "<Tools>" insert text "TEST_HELLO"

    End If
End Sub
End Class

however I want to also enter extra text after this tag when / if found
I am using VB.net

A:

Try:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    Dim text As String = IO.File.ReadAllText("C:\Example.xtp")
    Dim index As Integer = text.IndexOf("<Tools>")
    Dim countChars as integer
    countChars="<Tools>".Length
    If index >= 0 Then
       ' String is in file, starting at character "<Tools>" insert text "TEST_HELLO"
        text = text.Insert(index + countChars, "TEST_HELLO")
    End If
End Sub

Edit
If you want to write the final text to a/the file , there are many ways. I just suggest one, but you need to search and read and find what is suitable for you:
Dim Writer As System.IO.StreamWriter
Writer = New System.IO.StreamWriter("C:\Textfile.txt") '<-- Where to write to
Writer.Write(text)
Writer.Close()

