Visual Basic 2013 String Replacement
Posted
by
user3707612
on Stack Overflow
See other posts from Stack Overflow
or by user3707612
Published on 2014-06-04T15:06:05Z
Indexed on
2014/06/04
15:25 UTC
Read the original article
Hit count: 123
vb.net
|visual-studio
I found this code that replaces a string in a text file. But, I am trying to make it so that it replaces several strings in a text file.
My.Computer.FileSystem.WriteAllText("C:\windows\PrinterList2.txt", My.Computer.FileSystem.ReadAllText("C:\windows\PrinterList.txt").Replace("IT", "ADM-IT"), False)
For example, I need it to replace "IT" with "ADM-IT" and "AR" with "ADM-AR" and possibly a hundred or so more.
How can I get it to loop to do them all? Running this line of code over and over just overwrites the file with the last item for replacement.
Thanks in advance.
© Stack Overflow or respective owner