asp如何用FSO对象显示一个文本文件?
来源:asp之家 时间:2010-06-09 18:41:00
如何显示一个文本文件?
完整显示文本文件的代码如下:
Write(STRING)
WriteLine(STRING)
WriteBlankLines(LINES)
〈html〉
〈head〉
〈http-equiv="Content-Type" content="text/html;
charset=gb2312"〉
〈title〉春风精彩之文本文件显示〈/title〉
〈/head〉
〈body〉
<% LANGUAGE = VBScript %>
<%
Const ForReading = 1, ForWriting = 2, ForAppending = 3
' 参数为可选,决定输入/输出模式:①ForReading=1只读;②ForWriting=2 可读写;③ForAppending=3追加
Const TristateUseDefault = -2, TristateTrue = -1, TristateFalse = 0
' 参数为可选,指出以何种格式打开文件:①忽略此参数,以 ASCII格式打开文件;②TristateUseDefault=-2 以系统默认格式打开文件;③TristateTrue=-1 以 Unicode 格式打开文件;④TristateFalse=0 以 ASCII 格式打开文件,当然我们也可用OpenTextFile方法打开文件
Dim filename
filename = "test.txt"
' 缺省路径c:\win
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>
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
MSSQL中部分字段重复数据的删除方法
网页设计的色彩思考
带农历及节日的js日历源码
![](https://img.aspxhome.com/file/UploadPic/20108/1/201081174033330s.jpg)
分析与比较五种MySQL数据库可靠性方案
用javascript 转换外部链接样式
使用MySQL内建复制功能
Google的YSlow——Page Speed(附插件下载)
![](https://img.aspxhome.com/file/UploadPic/20099/27/page_speed_01-95s.gif)
添加到各大流行网摘 书签的代码
CSS选择符小讲
自定义用于ASP Web站点的 SQL 7.0 数据库
用JMail、CDONTS发送邮件asp源码
oracle 删除重复数据
MySQL时间字段究竟使用INT还是DateTime
WEB2.0网页制作标准教程(2)什么是名字空间
在ORACLE移动数据库文件
良好的css代码注释
在系统崩溃的时候如何恢复原有的数据
Div+CSS网页布局对SEO的影响漫谈
Jquery中Ajax 缓存带来的影响的解决方法
条件CSS的使用[译]
![](https://img.aspxhome.com/file/UploadPic/20093/12/01-51s.jpg)