·您的位置: 首页 » 资源教程 » 编程开发 » ASP » 怎样读取一个文本文件的内容

怎样读取一个文本文件的内容

类别: ASP教程  评论数:0 总得分:0
<%
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%">
-= 资 源 教 程 =-
文 章 搜 索
关键词:
类型:
范围:
纯粹空间 softpure.com
Copyright © 2006-2008 暖阳制作 版权所有
QQ: 15242663 (拒绝闲聊)  Email: faisun@sina.com
 纯粹空间 - 韩国酷站|酷站欣赏|教程大全|资源下载|免费博客|美女壁纸|设计素材|技术论坛   Valid XHTML 1.0 Transitional
百度搜索 谷歌搜索 Alexa搜索 | 粤ICP备19116064号-1