VB之fso-file
Sub writelog(filepath,logstr)
Const ForReading=1,ForWritting=2,ForAppdening=8
'创建文件
Dim fso,f
Dim teststr
Set fso=CreateObject("scripting.filesystemobject")
If fso.FileExists("D:test.txt") Then
MsgBox "Exist"
Else
MsgBox "Not Exist"
Set f=fso.CreateTextFile(filepath)
End If
'将数据写进文本中
Set f=fso.OpenTextFile(filepath,ForAppdening,false)
f.WriteLine logstr
f.Close
'将文本的数据读出来
Set f=fso.OpenTextFile(filepath,ForReading,False)
teststr=f.ReadLine
MsgBox teststr
f.Close
Set fso=Nothing
End Sub
writelog "D:\test.txt",Now()&"----执行自动化测试"