Microsoft VBScript runtime error '800a003e' Input past end of file |
To reproduce this error, simply create an empty (0 kb!) text file called a.txt, and place it in the same folder as the following ASP script:
<% set fso = CreateObject("Scripting.FileSystemObject") set fs = fso.opentextfile(server.mappath("a.txt")) f = fs.readall() fs.close: set fs = nothing: set fso = nothing %> |
To fix, you can simply check the size first:
<% set fso = CreateObject("Scripting.FileSystemObject") set fil = fso.getFile(server.mappath("a.txt")) if fil.size > 0 then set fs = fso.opentextfile(server.mappath("a.txt")) f = fs.readall() fs.close: set fs = nothing else f = "File was empty" end if set fil = nothing set fso = nothing response.write f %> |
This can also happen if you use the less efficient readline, and forget to use a while not fs.AtEndOfStream loop.