动网论坛,站长建站首选,国内使用量最多的论坛软件 动网论坛官方技术讨论区 站长工具 申请属于您自己的免费论坛
首页 | 新闻资讯 | 网站运营 | 网络编程 | 数据库 | 服务器 | 网页设计 | 图像媒体 | 网络应用 | 搜索优化 | 资源下载 | 动网主机 | DVBOX
    本站内  互联网 ASP论坛  ASP.Net论坛  PHP论坛
  
   Asp → 阅读文章

 filesystemobject组件的用法示例

作者来源: 
阅读 数 541 人次 , 2006-4-3 0:04:00 


''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' createlyrics
' 目的:
' 在文件夹中创建两个文本文件。
' 示范下面的内容
' - filesystemobject.createtextfile
' - textstream.writeline
' - textstream.write
' - textstream.writeblanklines
' - textstream.close
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

sub createlyrics(folder)

dim textstream

set textstream = folder.createtextfile("octopusgarden.txt")

textstream.write("octopus' garden ") ' 请注意,该语句不添加换行到文件中。
textstream.writeline("(by ringo starr)")
textstream.writeblanklines(1)
textstream.writeline("i'd like to be under the sea in an octopus' garden in the shade,")
textstream.writeline("he'd let us in, knows where we've been -- in his octopus' garden in the shade.")
textstream.writeblanklines(2)

textstream.close

set textstream = folder.createtextfile("bathroomwindow.txt")
textstream.writeline("she came in through the bathroom window (by lennon/mccartney)")
textstream.writeline("")
textstream.writeline("she came in through the bathroom window protected by a silver spoon")
textstream.writeline("but now she sucks her thumb and wanders by the banks of her own lagoon")
textstream.writeblanklines(2)
textstream.close

end sub

' getlyrics
' 目的:
' 显示 lyrics 文件的内容。
' 示范下面的内容
' - filesystemobject.opentextfile
' - filesystemobject.getfile
' - textstream.readall
' - textstream.close
' - file.openastextstream
' - textstream.atendofstream
' - textstream.readline
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

function getlyrics(fso)

dim textstream
dim s
dim file

' 有多种方法可用来打开一个文本文件,和多种方法来从文件读取数据。
' 这儿用了两种方法来打开文件和读取文件:

set textstream = fso.opentextfile(testfilepath & "\beatles\octopusgarden.txt", openfileforreading)

s = textstream.readall & newline & newline
textstream.close

set file = fso.getfile(testfilepath & "\beatles\bathroomwindow.txt")
set textstream = file.openastextstream(openfileforreading)
do while not textstream.atendofstream
s = s & textstream.readline & newline
loop
textstream.close

getlyrics = s

end function

 本文Tagsfso  组件  
 收藏本文  打印本文  论坛讨论  关闭窗口
· 上一篇:在线用表单建立文件夹
· 下一篇:组件对象开发Web应用的实例分析
· 用ASP和SQL实现基于Web的事件日历
· 谈谈sql查询的between
· 邮件发送简单例子-html文件
· ASP中数据库调用中常见错误的现象和解决
· JMail发送邮件代码


关于本站 | 联系我们 | 业务合作 | 客户案例 | 诚聘英才 | 广告合作 | 收藏本站
海口动网先锋网络科技有限公司版权所有
Copyright © 2000 - 2006 Cndw.Com
中华人民共和国电信与信息服务业务经营许可证编号 琼 ICP 020077