UFT基础_文件创建读写及文件夹创建删除

来源:互联网 发布:tm域名有必要注册吗 编辑:程序博客网 时间:2024/05/22 11:32
'Create the FileSystemObject'Set fso = CreateObject("Scripting.FileSystemObject")'Set logfile = FSO.OpenTextFile("D:\UFT\log.txt",1) '1 只读'   msgbox logfile.ReadAll'logfile.Close'Set logfile = Nothing'Set FSO = Nothing'读取txt文档'Sub ReadTxt(path)'   'Create the FileSystemObject'   Set fso = CreateObject("Scripting.FileSystemObject")'   Set logfile = FSO.OpenTextFile(path,1) '1 只读'   msgbox logfile.ReadAll'   logfile.Close'   Set logfile = Nothing'   Set FSO = Nothing'End Sub''Call ReadTxt("D:\UFT\log.txt")'顺序执行'Set FSO =CreateObject("Scripting.FileSystemObject")'Set logfile = FSO.OpenTextFile("D:\UFT\log.txt",8,true)'   logfile.WriteLine("ww")'   logfile.Close'   Set logfile = Nothing'   Set FSO = Nothing'写入txt'Sub WriteTxt(path,str)'   Set FSO =CreateObject("Scripting.FileSystemObject")'   Set logfile = FSO.OpenTextFile(path,2,true) '8 追加,2 覆盖写入'   logfile.WriteLine(str)'   logfile.Close'   Set logfile = Nothing'   Set FSO = Nothing'End Sub''Call WriteTxt("D:\UFT\log.txt","aa")'Set FSO =CreateObject("Scripting.FileSystemObject")'FSO.CreateFolder("D:\UFT\11")'FSO.DeleteFolder("D:\UFT\11")FSO.DeleteFile("D:\UFT\log.txt")
原创粉丝点击