By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,268 Members | 1,293 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,268 IT Pros & Developers. It's quick & easy.

Find/Replace in text file?

P: n/a
Hello,

Can anyone help me on how to find and replace text within a .txt file using
vb.net?

Any help would be greatly appreciated!
Thanks in advance.
Nov 21 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Dim fso, inputFile, outputFile
Dim str As String

fso = CreateObject("Scripting.FileSystemObject")

'1 means for reading

inputFile = fso.OpenTextFile("c:\testfile.txt", 1)

str = inputFile.ReadAll

'modify this string, replace required characters

str = Replace(str, "whatToReplace", "replaceWithThis")

'write back

outputFile = fso.CreateTextFile("c:\testfile.txt", True)

outputFile.Write(str)
--
Ilyan Mishiyev
IGM Consulting Corporation
Enterprise Web Solutions
www.igmcc.com
"Mark" <Ma**@discussions.microsoft.com> wrote in message
news:25**********************************@microsof t.com...
Hello,

Can anyone help me on how to find and replace text within a .txt file
using
vb.net?

Any help would be greatly appreciated!
Thanks in advance.

Nov 21 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.