Microsoft VBScript runtime error: Input past end of file error

前端 未结 2 1535
心在旅途
心在旅途 2021-01-27 09:21

I am getting this error:

\"C:\\se2.vbs(28, 6) Microsoft VBScript runtime error: Input past end of file\"

when I run my script (I italicized LINE

相关标签:
2条回答
  • 2021-01-27 09:27

    Looks like one of the files has zero size. Evidence:

    Option Explicit
    
    Const ForReading = 1
    
    Dim goFS : Set goFS = CreateObject("Scripting.FileSystemObject")
    
    Dim oFile
    For Each oFile In goFS.GetFolder("..\data\26878933").Files
        WScript.Echo oFile.Path, oFile.Size
        WScript.Echo oFile.OpenAsTextStream(ForReading).ReadAll()
        WScript.Echo "------"
    Next
    

    output:

    cscript 26878933.vbs
    ..\data\26878933\a.txt 3
    a
    
    ------
    ..\data\26878933\b.txt 0
    26878933.vbs(10, 5) Microsoft VBScript runtime error: Input past end of file
    
    0 讨论(0)
  • 2021-01-27 09:49

    I found out the problem. The error occurred when the script searched for a string in a BLANK TEXT FILE. I tried adding this:

    IF oFSO.GetFile(path).size <> 0 then    
    
        'Process text file then search for string.
    
    END IF
    
    0 讨论(0)
提交回复
热议问题