As the title say i would like to search a text file for a specific word and then start reading the text from that point forth.
A code snippet is the following
Dim path As String = "c:\temp\test.txt"
Dim readall As String
Dim i As Integer
If File.Exists(path) Then
File.Delete(path)
End If
Dim sw As StreamWriter = New StreamWriter(path)
sw.WriteLine("Hello")
sw.WriteLine("i am here")
sw.WriteLine("to test")
sw.WriteLine("the class")
sw.Close()
Dim sr As StreamReader = New StreamReader(path)
readall = sr.ReadToEnd
sr.Close()
So right now i have read the file and stored it to string readall.
How can i write back to the file but now starting from the word “to”
For instance the outpout text file would be
to test
the class
I hope i made myself clear
Search
readallfor the first occurrence of “to” and store the rest ofreadall, starting with “to”, to the variablestringToWrite:Then write
stringToWriteto file: