您现在的位置是:首页 >

hdfs文件读写流程 asp FSO 读写文件本文件实现代码

火烧 2021-09-28 15:38:32 1063
a FSO 读写文件本文件实现代码   a 己经过时有一段时间了 我来讲述一下利用a f o来实现文件读写操作 有需要学习的朋友可参考参考    AtE dOfStream  该属性表明是否已到达整个

asp FSO 读写文件本文件实现代码  

  asp己经过时有一段时间了 我来讲述一下利用asp fso来实现文件读写操作 有需要学习的朋友可参考参考

 

   AtEndOfStream

  该属性表明是否已到达整个文本文件末尾 其值为"TRUE"或"FALSE"

   CreateTextFile

  用来创建新的文本文件

   OpenTextFile()方法中的参数

  saucer(思归)所写的

 代码如下   Set f = fso OpenTextFile("c:testfile txt" ForWriting True)

  ForWriting值为 表示打开一个可写的文本文件 为 表示打开一个可读的文本文件 为 表示要附加数据

  True是表示如果没有这个文件 将新建一个 这个参数可选True或False 表明文件不存在时是否创建

  实例

  读文件

 代码如下   <% set myfileobject=server createobject("scripting filesystemobject") set mytextfile=myfileobject opentextfile("c:mydirtest txt") while not mytextfile atendofstream   response write(mytextfile readline) wend mytextfile close %>

   写文件

 代码如下   <% set myfileobject=server CreateObject("Scripting FileSystemObject") set mytextfile=myfileobject CreateTextFile("c:mydirtest txt") mytextfile WriteLine mytextfile close %>

   实例

hdfs文件读写流程 asp FSO 读写文件本文件实现代码

  FSO打造最简单的访问计数器

 代码如下  

  <%  set fs=Server CreateObject("Scripting FileSystemObject")  File = Server MapPath("counter txt")  Set txtr = fs OpenTextFile(File true) 打开只读文件file 如果不存在则新建  counter= 将计数器归零  If Not txtr atEndOfStream Then 先确定还没有到达结尾的位置  Line = txtr ReadLine 读取一行数据  else line= 否则设置初始值为 End If  counter=line+ 计数加 set tx = fs opentextfile(file true) 打开只写文件file  tx write counter 写入计数  response Write("<center>您是第<b>"&counter&"</b>位访客!</center>")  输出计数  %>

  在需要统计和显示计数的地方可以用include的方式引入这个文档

 代码如下  

  <! #include file="counter asp" >

   但是如果是之类静态页面 则可以通过script脚本的方式来使用这个简单的计数器

  那么Counter asp则需要这么写了

 代码如下  

  <%

  response Write("document write(""<center>您是第<b>"&counter&"</b>位访客!</center>"");")

  %>

  需要引用的静态页里可以通过Script脚本来使用计数器

 代码如下   lishixinzhi/Article/program/net/201311/14234  
永远跟党走
  • 如果你觉得本站很棒,可以通过扫码支付打赏哦!

    • 微信收款码
    • 支付宝收款码