数据读取中...
 您当前位置:惠州维修 -> 网络-> asp技术交流 文章搜索:  
filesystemobject组件的用法示例
作者:转载 来源:惠州维修
日期: 2006-11-20
放大字体显示 缩小字体显示 打印文章 推荐给朋友



''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' 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


原作者:赖皮王子
来 源:chinaasp

文章页数:[1] 
帮助你我他: 1.我有问题请教 2.我要投稿>>>
更多相关资料搜索:
热点文章
最新文章
相关文章
版权申明:除部分特别声明不要转载,或者授权本站独家播发的文章外,大家可以自由转载本站的原创文章,但原作者和来自本站的链接必须保留(非本站原创的,按照原来自一节,自行链接)。文章版权归本站和作者共有。
转载要求:转载之图片、文件,链接请不要盗链到本站,且不准打上各自站点的水印,亦不能抹去本站水印。
特别注意:本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有。
发表评论  打印  刷新  推荐给朋友  返回顶部  关闭

网上大名: