Replacing a String in Multiple Text Files
Hi VBForums,
I have the following code which finds and replaces a string in a specified text file.
Code:
Dim FSO, InputFile, OutputFile
Dim s As String
FSO = CreateObject("Scripting.FileSystemObject")
InputFile = FSO.OpenTextFile("c:\File.txt", 1)
s = InputFile.ReadAll
s = Replace(s, TextBox1.Text, TextBox2.Text)
OutputFile = FSO.CreateTextFile("c:\File.txt", True)
OutputFile.Write(s)
I need the code to find and replace a string in multiple text files. I've looked into using the following code but I don't know how to overwrite the text file which is been read.
Code:
InputFile = FSO.OpenTextFile("c:\File.txt", 1)
Any thoughts?
Thanks,
Sebkeh
Re: Replacing a String in Multiple Text Files
Code:
InputFile = FSO.OpenTextFile("c:\*.txt", 1)
*
Re: Replacing a String in Multiple Text Files
This looks more like VBScript to me, not exactly VB.net.