实践出真知!

vbs中对文件的处理_读取文件

上一篇 / 下一篇  2008-04-15 10:32:05 / 个人分类:语言学习

从文本文件读取数据,则使用TextStream对象的ReadReadLineReadAll方法:51Testing软件测试网z"q!{6y,cHj
read:从文件读取指定数量的字符。
O7c"B s+DG/e9~0readline:读取一整行(一直到但不包括新行字符)。
$fcjS r0R ])~:q0readall:读取文本文件的整个内容。51Testing软件测试网(A2gJlg,j.bZ
例子:51Testing软件测试网+@jn_?,r&bMS
Sub ReadFiles
er6WGU@ [ `0
   Dim fso, f1, ts, s
Y8XH(^5|UMRFa4x0   Const ForReading = 1
KNaP e,_:j0   Set fso = CreateObject("scrīpting.FileSystemObject")51Testing软件测试网&l5b3Y-S.r%t ~
   Set f1 = fso.CreateTextFile("c:\testfile.txt", True)51Testing软件测试网7T{F(f-M Qbm
   '写一行。51Testing软件测试网 NYo/G-Y S(tY2~\X
   Response.Write "Writing file <br>"
;mM X-A7S3h7uE:b0   f1.WriteLine "Hello World"
0S3?N i7M0   f1.WriteBlankLines(1)51Testing软件测试网 P|7V r3Y`o0R
   f1.Close51Testing软件测试网*Gl!s,wI:ZvU
   '读取文件的内容。
%Vi.m@)m6cM0   Response.Write "Reading file <br>"
6Y Z NfL)~0   Set ts = fso.OpenTextFile("c:\testfile.txt", ForReading)51Testing软件测试网)?-d,x7bb j9Xd [0W
   s = ts.ReadLine51Testing软件测试网0I&\Cshe?7e,ea(H
   Response.Write "File contents = '" & s & "'"51Testing软件测试网 MuZx P
   ts.Close51Testing软件测试网#Q9R'Ae2F
End Sub
51Testing软件测试网8U7G5~ A6A5Jmow

TAG: 语言学习

 

评分:0

我来说两句

日历

« 2024-04-01  
 123456
78910111213
14151617181920
21222324252627
282930    

数据统计

  • 访问量: 4383
  • 日志数: 8
  • 文件数: 1
  • 建立时间: 2008-01-30
  • 更新时间: 2008-06-16

RSS订阅

Open Toolbar