ASP读取文本文件内容的方法

来源:爱站网时间:2020-10-09编辑:网友分享
在学习ASP的时候是不是有小伙伴们会好奇要怎么读取文本文件内容呢?那么今天小编就以自己的知识为大家介绍读取文本文件内容的方法。

在学习ASP的时候是不是有小伙伴们会好奇要怎么读取文本文件内容呢?那么今天小编就以自己的知识为大家介绍ASP读取文本文件内容的方法。

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.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

 





 
 






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读取文本文件内容的方法,今天小编就跟大家分享到这里,更多精彩内容欢迎继续关注爱站技术频道。 

上一篇:asp使用discuz会员系统的技巧

下一篇:自动提示文本框效果代码的JavaScript实现

您可能感兴趣的文章

相关阅读

热门软件源码

最新软件源码下载