上一篇:用ASP做一个TOP COOL的站内搜索 >>
怎样读取一个文本文件的内容?
from a text file
<!--Start of ASP Code---->
<%
@#by James Seymour, http://jamesdot.org
Dim write
Dim fileSysObj, tf, read
@# Read the read.txt
@# Store the file name where the Information is stored into a variable called read
read = "read.txt"
@# Retrieve the fullpath of the read file
read = LEFT(Server.Mappath(Request.ServerVariables("PATH_INFO")), InStrRev(Server.Mappath
(Request.ServerVariables("PATH_INFO")), "\")) & read
@# Create an instance of FileSystem Object and store it into a variable called fileSysObj
Set fileSysObj = createObject("Scripting.FileSystemObject")
@# Check whether the read file exists
IF (fileSysObj.FileExists(read)) Then
@# if the file exists, then open it for reading
Set tf = filesysobj.OpenTextFile(read, 1)
read = tf.ReadLine
tf.Close
ELSE
@# if you can@#t find read.text, display default message
read = "I can@#t find the file read.txt! So this is my default message."
END IF
%>
@# table the displays the read.txt file
<div align="center">
<center>
<table border="0" width="40%" cellspacing="0" cellpadding="0">
<tr>
<td width="100%" bgcolor="#EEEECC"><B><%=read%></B>
</td>
</tr>
<tr>
<td width="100%">
<!-- End of the ASP -->
use the code above, click and drag your mouse over the code to highlight it. Then right click on the
highlighted code and click "Copy." Now you may paste it into your code editor.
下一篇:在线用表单建立文件夹 >>
相关文章:
- · 读取目录下的文件得到一个数组
- · 奇妙的文件系统对象组件
- · ASP.NET2.0导航功能之配置会员和角色
- · C#+ASP.NET开发基于Web的RSS阅读器
- · 在ASP.NET程序中实现语音合成
- · 在Apache上调试ASP.NET 1.1/2.0代码
- · ASP.NET初学:建立ASP.NET开发平台
- · 用ASP.Net和Access编写留言本
- · .net中发mail到hotmail中乱码问题的解决
- · ASP.Net应用程序的多进程模型
- · 用 ASP.NET 2.0 改进的 ViewState 加快网站速度
- · 在ASP.NET中使用Session常见问题集锦
- · ASP.NET文章管理系统:系统分析与设计
- · asp.net开发常用技巧收集
- · ASP.NET 2.0运行时简要分析
- · 在IIS6.0下ASP .NET 的版本冲突问题
- · ASP.NET:目录的遍历
- · ASP.NET:目录创建和删除
- · ASP.Net:基于窗体的身份验证
- · 防刷新重复提交、防后退方法
- · ASP.NET程序实现博客日历
- · 掌握Web窗体的生命周期与状态管理
- · ASP.NET 移动 Web 窗体和 ASP.NET 兼容性
- · ASP.NET入门随想之多态、接口与委托
- · ASP.Net项目出错处理方法汇总
- · 利用ASP.NET程序来访问Excel文档
- · ASP.NET应用程序开发七大技巧
- · VB.NET开发人员必备参考10本书目
- · 用ADO.NET处理层次数据
- · ASP.NET实现在服务器端控制网页
- · 用ASP.NET向Javascript传递变量
- · ASP.NET实现抓取网页中的链接
- · 在ASP.NET 2.0中实现数据的绑定
- · ASP.NET随机显示数据库记录
- · ASP.Net生成业务数据的统计图形
- · 剖析ASP.NET2.0导航功能之控制地图信息
- · ASP.Net中利用CSS实现多界面的方法
- · ASP.NET 常见问题
