最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
怎样读取一个文本文件的内容
时间:2022-06-30 11:49:19 编辑:袖梨 来源:一聚教程网
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
'by James Seymour, http://*jamesdot*.o*rg
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
from a text file
'by James Seymour, http://*jamesdot*.o*rg
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
|
|
|
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. |
相关文章
- 女神漫画免费下载最新版本动漫入口页面-女神漫画在线观看安装包动漫入口 02-08
- 哔哩哔哩b站官网直达-bilibili网站主页一键进入 02-08
- 365日历网页版快捷登录-365日历网页版一键登录入口 02-08
- 免费看短视频的精品app-追剧无广告的必备app推荐 02-08
- 微信对话生成器-无水印版免费下载 02-08
- 豆包网页版应用生成器-豆包AI应用一键生成 02-08