当前位置: 移动技术网 > IT编程>开发语言>其他编程 > 如何读取文本文件的内容?

如何读取文本文件的内容?

2017年12月08日  | 移动技术网IT编程  | 我要评论

<%
dim write
dim filesysobj, tf, read
read = "intels.txt"
'
读取intels.txt.

read = left(server.mappath(request.servervariables("path_info")), instrrev(server.mappath(request.servervariables("path_info")), "\")) & read
'
检索要读的文件的完整路径.

set filesysobj = createobject("scripting.filesystemobject")
'
创建一个 filesystem object 实例,并把它保存到 filesysobj 的变量中

if (filesysobj.fileexists(read)) then
set tf = filesysobj.opentextfile(read, 1)

' 如果文件在,就打开读取.

read = tf.readline
tf.close
else
read = "
,找不到这个文件!"
'
如果文件不存在,发出错误提示.
end if
%>

<html>

<body>

<p align="center">千花飞舞之读取文本内容</p>

 

<div align="center">

<div align="center">
<center>
<table border="0" width="40%" cellspacing="0" cellpadding="0">
<tr>
<td width="100%" bgcolor="green"><b><%=read%></b>
</td>
</tr>
<tr>
<td width="100%">

</table>

</center></div>

</body></html>

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网