国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁(yè) > 編程 > ASP > 正文

怎樣讀取一個(gè)文本文件的內(nèi)容?

2024-05-04 11:02:31
字體:
來(lái)源:轉(zhuǎn)載
供稿:網(wǎng)友
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.

發(fā)表評(píng)論 共有條評(píng)論
用戶(hù)名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 益阳市| 阳江市| 永靖县| 万州区| 庆云县| 巩义市| 洛浦县| 上思县| 东宁县| 金川县| 东乌珠穆沁旗| 神农架林区| 舞阳县| 苏州市| 新邵县| 丽江市| 元阳县| 东宁县| 左权县| 海淀区| 盐源县| 溆浦县| 平顺县| 弥渡县| 古浪县| 高清| 龙口市| 灵武市| 齐齐哈尔市| 扎囊县| 榕江县| 昌都县| 来宾市| 龙里县| 建瓯市| 呼和浩特市| 关岭| 家居| 汪清县| 安平县| 荣成市|