如何在asp当中读文本文件?

rangday 2003-07-17 03:40:16
大家好!我想在本地计算机上实现读去文本文件,可以否?我用的是
Set MyFileObject=Server.CreateObject("Scripting.FileSystemObject")
可一直是报错不知道是怎么回事?各位请指教!!不胜感激!
...全文
20 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
rangday 2003-07-17
  • 打赏
  • 举报
回复
可能没有那个组件还是怎么回事?代码如下:
<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title>New Page 1</title>
</head>

<body>
<% LANGUAGE = VBScript
%>
<%
Const ForReading = 1, ForWriting = 2, ForAppending = 8 
Const TristateUseDefault = -2, TristateTrue = -1, TristateFalse = 0 
Dim filename 
filename = "test.txt"
Set fs = CreateObject("Scripting.FileSystemObject") 
Set f = fs.GetFile(filename) 
Set readf = f.OpenAsTextStream(ForReading,TristateFalse) 
s = readf.ReadLine 
Do While readf.AtEndOfLine <> True 
s = readf.ReadLine 
Response.write s 
Loop 
readf.close
%>
</body>

</html>
kyoxue 2003-07-17
  • 打赏
  • 举报
回复
当然可以读了
把你的代码贴出来,,兄弟们帮你改!
Cooly 2003-07-17
  • 打赏
  • 举报
回复
检查机器上是否有Microsoft Scripting Runtime组件
qiangtian 2003-07-17
  • 打赏
  • 举报
回复
把错误贴出来看看

28,390

社区成员

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

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