benniesanders
Programmer
Greetings, I am *trying* to use the following code to search for and replace a phone number in a gazillion files:
however, when I run this, I am getting the following error:
Invalid procedure call or argument on line 18
Line 18 is:
Set objTextStream = objFile.OpenAsTextStream(ForReading)
I am not smart enough to figure this out myself. I would appreciate any thoughts or better ideas or is this even the correct way to do this... Many thanks in advance for your help.
Code:
<%
Dim objFSO, objFolder
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.GetFolder("d:\inetpub\[URL unfurl="true"]wwwroot\myfolder")[/URL]
Dim objFile
For Each objFile in objFolder.Files
' Do something to the file
Dim objTextStream
Dim strContent
Set objTextStream = objFile.OpenAsTextStream(ForReading)
strContent = objTextStream.ReadAll()
Call objTextStream.Close()
Set objTextStream = Nothing
strContent = Replace(strContent,"old phone number", "new phone number")
Set objTextStream = objFile.OpenAsTextStream(ForWriting)
Call objTextStream.Write(strContent)
Call objTextStream.Close()
Set objTextStream = Nothing
Next'objFile
%>
Invalid procedure call or argument on line 18
Line 18 is:
Set objTextStream = objFile.OpenAsTextStream(ForReading)
I am not smart enough to figure this out myself. I would appreciate any thoughts or better ideas or is this even the correct way to do this... Many thanks in advance for your help.