主页 > 知识库 > 怎样读取一个文本文件的内容?

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

热门标签:怎么在地图标注自己 个人可以办理400电话么 外呼系统API接口 修改地图标注 武夷山旅游地图标注 凤台百度地图标注店 莱西电子地图标注 金昌电话机器人价格 县域地图标注打印店
Ever want to know how to display the contents of a text document using ASP. Here is a easy way to read
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.

标签:南京 凉山 赤峰 清远 上海 邢台 通辽 楚雄

巨人网络通讯声明:本文标题《怎样读取一个文本文件的内容?》,本文关键词  怎样,读取,一个,文本,文件,;如发现本文内容存在版权问题,烦请提供相关信息告之我们,我们将及时沟通与处理。本站内容系统采集于网络,涉及言论、版权与本站无关。
  • 相关文章
  • 下面列出与本文章《怎样读取一个文本文件的内容?》相关的同类信息!
  • 本页收集关于怎样读取一个文本文件的内容?的相关信息资讯供网民参考!
  • 推荐文章