CSDN首页 空间 新闻 论坛 Blog 下载 读书 网摘 搜索 .NET Java 视频 接项目 求职 在线学习 买书 程序员 通知
不看会后悔的Windows XP之经验谈 简单快捷DIY实用家庭影院
CSDN社区
搜索 收藏 打印 关闭
CSDN社区 >  Web 开发 >  ASP

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

楼主lessbird()2002-11-08 11:06:19 在 Web 开发 / ASP 提问

怎样读取一个文本文件的内容? 问题点数:100、回复次数:1Top

1 楼popcode(枫.net)回复于 2002-11-08 11:07:14 得分 100

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

相关问题

  • Query怎样才能读取文本文件的内容
  • 怎样打开文件?读取文本文件中的内容????
  • 怎样顺序读取文本文件中的内容?
  • 怎样将置顶位置的文本文件中的内容读取出来?
  • 怎样清除文本文件内容?
  • 如何快速读取文本文件的内容?
  • 如何读取文本文件的内容?特急!!
  • 怎么从文本文件按行读取内容????
  • 如何读取文本文件里的内容啊
  • 怎么读取文本文件的内容!

关键词

  • 内容
  • code
  • 读取一个文本文件
  • highlighted
  • click
  • a text
  • displays
  • read

得分解答快速导航

  • 帖主:lessbird
  • popcode

相关链接

  • Web开发类图书

广告也精彩

反馈

请通过下述方式给我们反馈
反馈
提问
网站简介|广告服务|VIP资费标准|银行汇款帐号|网站地图|帮助|联系方式|诚聘英才|English|问题报告
北京创新乐知广告有限公司 版权所有, 京 ICP 证 070598 号
世纪乐知(北京)网络技术有限公司 提供技术支持
Copyright © 2000-2008, CSDN.NET, All Rights Reserved
GongshangLogo