asp如何读取一个文件内容?

来源:asp之家 时间:2009-11-19 17:23:00 

代码和说明如下:

<%
Const ForReading = 1    
 ' 设定常量       
Const Create = False 
' 输入输出模式
Dim FSO 
' FileSystemObject
Dim TS  
' TextStreamObject
Dim strLine  
' 用来存储行
Dim strFileName
' 用来储存文件名
' 以上四行声明局部变量
strFileName = Server.MapPath("textfile.txt")
Set FSO = Server.CreateObject("Scripting.FileSystemObject")
Set TS = FSO.OpenTextFile(strFileName, ForReading, Create)
' 用Opentextfile方法打开文本文件Method to Open the text File
If not TS.AtEndOfStream Then                  
  Do While not TS.AtendOfStream            
    strLine = TS.ReadLine   
' 每次读出一行
    Response.Write strLine   
   ' 显示该行
    Response.Write "<br>"                  
  loop
' 循环
End If
TS.Close        
Set TS = Nothing
Set FSO = Nothing
' 关闭对象和局部变量并清空
%>

标签:文件,asp,fso
0
投稿

猜你喜欢

  • 中文段首不需要空两格

    2010-04-23 20:31:00
  • javascript用回车键实现Tab键功能

    2009-07-05 18:40:00
  • Oracle数据库游标使用大全

    2008-03-04 18:24:00
  • IE下Flash内容刷新后消失问题

    2008-01-02 12:38:00
  • 用面包屑来简化多层的tabs

    2011-06-16 20:32:54
  • CSS像素图制作攻略

    2009-05-19 19:32:00
  • asp如何用JMail同时给多人发信?

    2010-06-12 12:52:00
  • 利用索引提高SQL Server数据处理的效率

    2009-01-08 15:32:00
  • javascript设计模式交流(一)Singleton Pattern

    2007-11-29 13:20:00
  • JavaScript Memoization

    2008-05-01 12:48:00
  • 用SQL语句完成SQL Server数据库的修复

    2008-11-24 20:49:00
  • 30步检查SQL Server安全列表

    2008-12-18 14:28:00
  • ASP利用Google实现在线翻译功能

    2010-03-07 17:28:00
  • 四种方法在SQL Server数据库中成批导入数据

    2009-02-19 17:25:00
  • XML卷之实战锦囊(1):动态排序

    2008-09-05 17:20:00
  • asp函数收藏

    2009-04-21 13:10:00
  • SQL存储过程初探

    2009-09-09 14:22:00
  • 最简洁的SQL多重查询的解决方案

    2005-09-12 16:31:00
  • 如何调试 XMLHttpRequest

    2008-08-15 13:59:00
  • 国外404错误页面的创意设计欣赏

    2007-08-19 15:44:00
  • asp之家 网络编程 m.aspxhome.com