社区
ASP
帖子详情
如何用asp读文本文件。
guozhiw
2003-06-14 01:32:56
等待中。。。
...全文
52
9
打赏
收藏
如何用asp读文本文件。
等待中。。。
复制链接
扫一扫
分享
转发到动态
举报
写回复
配置赞助广告
用AI写文章
9 条
回复
切换为时间正序
请发表友善的回复…
发表回复
打赏红包
Ngod
2003-06-14
打赏
举报
回复
method2
<% Option Explicit
Const Filename = "/readme.txt" ' file to read
Const ForReading = 1, ForWriting = 2, ForAppending = 3
Const TristateUseDefault = -2, TristateTrue = -1, TristateFalse = 0
' Create a filesystem object
Dim FSO
set FSO = server.createObject("Scripting.FileSystemObject")
' Map the logical path to the physical system path
Dim Filepath
Filepath = Server.MapPath(Filename)
if FSO.FileExists(Filepath) Then
Set TextStream = FSO.OpenTextFile(Filepath, ForReading, False, _
TristateUseDefault)
' Read file in one hit
Dim Contents
Contents = TextStream.ReadAll
Response.write "<pre>" & Contents & "</pre><hr>"
TextStream.Close
Set TextStream = nothing
Else
Response.Write "<h3><i><font color=red> File " & Filename &_
" does not exist</font></i></h3>"
End If
Set FSO = nothing
%>
Ngod
2003-06-14
打赏
举报
回复
method1
<% Option Explicit
Const Filename = "/readme.txt" ' file to read
Const ForReading = 1, ForWriting = 2, ForAppending = 3
Const TristateUseDefault = -2, TristateTrue = -1, TristateFalse = 0
' Create a filesystem object
Dim FSO
set FSO = server.createObject("Scripting.FileSystemObject")
' Map the logical path to the physical system path
Dim Filepath
Filepath = Server.MapPath(Filename)
if FSO.FileExists(Filepath) Then
' Get a handle to the file
Dim file
set file = FSO.GetFile(Filepath)
' Get some info about the file
Dim FileSize
FileSize = file.Size
Response.Write "<p><b>File: " & Filename & " (size " & FileSize &_
" bytes)</b></p><hr>"
Response.Write "<pre>"
' Open the file
Dim TextStream
Set TextStream = file.OpenAsTextStream(ForReading, _
TristateUseDefault)
' Read the file line by line
Do While Not TextStream.AtEndOfStream
Dim Line
Line = TextStream.readline
' Do something with "Line"
Line = Line & vbCRLF
Response.write Line
Loop
Response.Write "</pre><hr>"
Set TextStream = nothing
Else
Response.Write "<h3><i><font color=red> File " & Filename &_
" does not exist</font></i></h3>"
End If
Set FSO = nothing
%>
fason
2003-06-14
打赏
举报
回复
http://www.aspsky.net/article/index.asp?classid=2&Nclassid=33
freezh
2003-06-14
打赏
举报
回复
WriteLine为写
readline为读
freezh
2003-06-14
打赏
举报
回复
这是一个读写的例 子
Sub ReadFiles
Dim fso, f1, ts, s
Const ForReading = 1
Set fso = CreateObject("Scripting.FileSystemObject")
Set f1 = fso.CreateTextFile("c:\testfile.txt", True)
'' 写一行。
Response.Write "Writing file <br>"
f1.WriteLine "Hello World"
f1.WriteBlankLines(1)
f1.Close
'' 读取文件的内容。
Response.Write "Reading file <br>"
Set ts = fso.OpenTextFile("c:\testfile.txt", ForReading)
s = ts.ReadLine
Response.Write "File contents = ''" & s & "''"
ts.Close
End Sub
ddboy
2003-06-14
打赏
举报
回复
<%
Set fso = Server.CreateObject("Scripting.FileSystemObject")
Set f = fso.OpenTextFile(FileName, 1, False)
str = f.ReadAll
f.close
Set fso = Nothing
%>
fso其它方法或对象,参见VBScript帮助
freezh
2003-06-14
打赏
举报
回复
Dim fso, f1
Set fso = CreateObject("Scripting.FileSystemObject")
Set f1 = fso.CreateTextFile("c:\testfile.txt", True)
叶子哟
2003-06-14
打赏
举报
回复
fso没问题!新建修改均可以
freezh
2003-06-14
打赏
举报
回复
使用fso
ASP
读
写文件函数
利用AdoDb.Stream对象来
读
取UTF-8格式的
文本文件
利用AdoDb.Stream对象来写入UTF-8格式的
文本文件
无数据库
ASP
目录直
读
生成产品列表文本名称清单完美嵌入列表的程序
经典强悍的目录直
读
程序,做到无数据库输出产品列表,曾在铺中发表过一次,这次再次完善加入文本名称清单,嵌入产品列表,解决了老网站产品更新的大难题。我做网站维护一个人管理几百家客户,由于大部分老网站都是...
ASP
.NET Core 基础 部署至Linux
第一讲什么是
ASP
.NET Core 第二讲
ASP
.NET Core 基本架构 第三讲
ASP
.NET Core OWIN 第四讲 创建
ASP
.NET Core第一个程序 第五讲
ASP
.NET Core 运行静态文件1 第六章
ASP
.NET Core运行默认文件 第七讲
ASP
.NET Core ...
C#学习笔记_20100614
学习过程中的体会,包括: C#中关键字的小提示 ...创建一个
文本文件
并写入文本 序列化对象到文件 创建一个
文本文件
并写入文本 文件夹拷贝 使用C#解析简单XML
读
XML文件 用 XmlWriter写 XML文件 插入数据到 XML文档
asp
文件管理器-2.0可上传.rar
1.增删改
读
文件。 2.轻松设置管理路径。 3.监测文件夹大小,可控制定用户上传空间总量。 4.图片裁切后上传。批量上传。 5.可轻松整合到富文本编辑器 6.响应式,兼容PC端和移动端。
ASP
28,391
社区成员
357,060
社区内容
发帖
与我相关
我的任务
ASP
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
复制链接
扫一扫
分享
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
加入社区
获取链接或二维码
近7日
近30日
至今
加载中
查看更多榜单
社区公告
暂无公告
试试用AI创作助手写篇文章吧
+ 用AI写文章