|I'm writing a program to compensate for a bug in our vendor's software. I have about 6,000 text files I need to read. The first part of my script will combine all files into a single file. The reason I'm doing this is because I don't want to use WSH to open and close 6,000 text files to do a find/replace. It's easier to combine all files into a single file, then do a find/replace on a single file. I then string certain data together into an SQL file in order to import into our database.|
The problem I'm having is that once the 6,000 text files are combined into a single file, the size of the file is 182MB. I'm not ashamed to say that I found the below section of code on the Microsoft site. A few seconds after the below section of code executes, I receive the following error:
"Out of string space: 'Replace'"
What can I add to this code to prevent this error from occuring?
Const ForReading = 1
Const ForWriting = 2
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set wshShell = WScript.CreateObject( "WScript.Shell" )
Set objFile = objFSO.OpenTextFile("C:\Folder\File.txt", ForReading)
strText = objFile.ReadAll
strNewText = Replace(strText, "12345 ", "REMOVED ")
Set objFile = objFSO.OpenTextFile("C:\Folder\File.txt", ForWriting)