If you have a 6GB file that might have a 2GB line somewhere, this code will find it!
Code: Select all
Const ForReading = 1
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.OpenTextFile ("c:\aemail\2005.txt", ForReading)
maxLength = 0
Do Until objTextFile.AtEndOfStream
strCharacters = objTextFile.Read(16384)
for i = 1 to len(strCharacters)
test = Mid(strCharacters,i,1)
if (test = chr(13)) or (test = chr(10)) then
if count > maxLength then
maxLength = count
' WScript.Echo "New longest line: " & maxLength
end if
count = 0
else
count = count + 1
end if
Next
Loop
objTextFile.Close
WScript.Echo "Longest line was: " & maxLength