Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27349

VS 2008 How to REPLACE more lines in a document

$
0
0
Hi, i'd like to replace few lines in my document but i don't know how to make working this code (it only changes one line)
for ex. from my test.txt i want to
search for "Replacetext1" and replace with "Hello!"
search for "Hi" and replace with "Hi!"
Then save in mod.txt

Dim sR As New IO.StreamReader(Application.StartupPath + "test.txt")
Dim sW As New IO.StreamWriter(Application.StartupPath + "mod.txt")
While Not (sR.EndOfStream)
sW.WriteLine(sR.ReadLine.Replace("Replacetext1", "Hello!"))
End While

sR.Close()
sW.Close()


Thank you

Viewing all articles
Browse latest Browse all 27349

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>