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

sh860917

sh860917

2016-01-29 18:15

怎样读取一个文本文件的内容?,怎样读取一个文本文件的内容?
  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.

 
展开更多 50%)
分享

猜你喜欢

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

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

html读出文本文件内容

Web开发
html读出文本文件内容

s8lol主宰符文怎么配

英雄联盟 网络游戏
s8lol主宰符文怎么配

ASP入门基础教程-读取文本文件

Web开发
ASP入门基础教程-读取文本文件

用ADODB.Stream代替FSO读取文本文件

ASP
用ADODB.Stream代替FSO读取文本文件

lol偷钱流符文搭配推荐

英雄联盟 网络游戏
lol偷钱流符文搭配推荐

INI参数(文本文件)的读写

编程语言 网络编程
INI参数(文本文件)的读写

Word文档批量转为文本文件

办公软件
Word文档批量转为文本文件

lolAD刺客新符文搭配推荐

英雄联盟
lolAD刺客新符文搭配推荐

Word文档中“文字、图形、图片”的组合

Word文档中“文字、图形、图片”的组合

巧做Win XP自动恢复系统修复盘

巧做Win XP自动恢复系统修复盘
下拉加载更多内容 ↓