ASP读取文件的问题

missboy 2003-10-20 05:05:12

对ASP不熟悉,下面的一段很基本的程序运行的时候提示网页无法显示,比较郁闷,请大哥们帮着分析一下:

<%

set fso=Server.Createobject("Scripting.FileSystemObject")
path="session.txt"
'open the file
set file=fso.opentextfile(path,1,False)

'do until file.AtEndOfStream
Response.write(file.ReadLine() & " ")
loop
'close and clean up
file.close
set file = nothing
set fso = nothing
%>
...全文
81 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
xiaobird1 2003-10-20
  • 打赏
  • 举报
回复
path=Server.MapPath(".") & "session.txt"
相干什么?


path=Server.MapPath(".\session.txt") ??

missboy 2003-10-20
  • 打赏
  • 举报
回复

OK,这样就可以了:
<%

set fso=Server.Createobject("Scripting.FileSystemObject")
'path="session.txt"
path=Server.MapPath("session.txt")
'open the file
set file=fso.opentextfile(path,1,False)

'do until file.AtEndOfStream
Response.write(file.ReadLine() & " ")
'loop
'close and clean up
file.close
set file = nothing
set fso = nothing
%>

看来是MAPPATH的问题/谢谢!

我用
path=Server.MapPath(".") & "session.txt"
却不行
xiaobird1 2003-10-20
  • 打赏
  • 举报
回复
无法显示网页?你的iis配置没有出错把?

还有你的session.txt是否在当前目录?

这可要先保证哦!
missboy 2003-10-20
  • 打赏
  • 举报
回复

对不起,笔误,注释掉也不行,
xiaobird1 2003-10-20
  • 打赏
  • 举报
回复
不行,使用
path=Server.MapPath("session.txt")
试试
xiaobird1 2003-10-20
  • 打赏
  • 举报
回复
把loop注释掉试试

28,390

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧