分享、学习、提高
2008/01/13 12:26
文章作者:Enjoy 转载请注明原文链接。
Function getfile(filename)
  dim f
  if fso.fileExists(server.MapPath(filename)) then
  set f = fso.OpenTextFile(server.MapPath(filename))
  Response.write f.ReadAll
  set f = nothing
  end if
End Function

调用时出现:

Microsoft VBScript 运行时错误 错误 '800a003e'  

输入超出了文件尾  

/function.asp,行35

第35行就是Response.write f.ReadAll这句。
这是一段读取已经存在的文件,并输出文件内容的函数。但当这个文件没有内容时,就会出这种错误提示。
查了文档,ReadAll不会自己判断是否到文件尾,只好,加了个atendofstream的判断语句,测试OK。

更改后的代码为
Function getfile(filename)
  dim f
  if fso.fileExists(server.MapPath(filename)) then
  set f = fso.OpenTextFile(server.MapPath(filename))
  if not f.atendofstream then  
  Response.write f.ReadAll
  end if
  set f = nothing
  end if
End Function

lil
2012/04/12 02:07
谢谢,很好的提示。
dushu520 Homepage
2009/04/16 13:33
很好,解决了我的一个难题

读书就到读书520
2009/02/28 20:26
感谢
分页: 1/1 第一页 1 最后页
发表评论
表情
emotemotemotemotemot
打开HTML
打开UBB
打开表情
隐藏
昵称   密码   游客无需密码
网址   电邮   [注册]
               

验证码 不区分大小写