分享、学习、提高
2008/01/13 12:26
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

发表评论
表情
emotemotemotemotemot
打开HTML
打开UBB
打开表情
隐藏
昵称   密码   游客无需密码
网址   电邮   [注册]