如何读取文本文件的内容?_编程10000问教程-查字典教程网
如何读取文本文件的内容?
如何读取文本文件的内容?
发布时间:2016-12-29 来源:查字典编辑
摘要:

<%

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>

相关阅读
推荐文章
猜你喜欢
附近的人在看
推荐阅读
拓展阅读
  • 大家都在看
  • 小编推荐
  • 猜你喜欢
  • 最新编程10000问学习
    热门编程10000问学习
    编程开发子分类