TA的每日心情 | 郁闷 2018-11-15 14:58 |
---|
签到天数: 2 天 连续签到: 2 天 [LV.1]测试小兵
|
用VBS写的QTP报告脚本,该脚本有个缺点,就是对脚本存放的目录有要求,请问可以怎样改进?
Dim sourcepath
sourcepath = "D:\QTP"
Call FolderAttributes(sourcepath)
Sub FolderAttributes(sourcepath)
Dim fso,objset,objFolders,FolderName,i
i = 0
Set fso = CreateObject("Scripting.FileSystemObject")
'使用GetFolder方法来返回Folder对象
Set objset = fso.getFolder(sourcepath)
'SubFolders属性将返回所有子文件夹对应的Folder集合
Set objFolders = objset.SubFolders
'遍历Folder集合,统计出共有多少个文件夹,及相关文件夹的名字
For Each objFolder in objFolders
Set objset1=fso.GetFolder(objFolder)
Set objFloders1=objset1.SubFolders
For each objFolder1 in objFloders1
Set objset2=fso.GetFolder(objFolder1)
Set objFloders2=objset2.SubFolders
For each objFolder2 in objFloders2
Call scwj(objFolder2)
Next
next
Next
Set fso = nothing
End Sub
sub scwj(filename) '删除文件
Set fso = CreateObject("Scripting.FileSystemObject")
if regExpTest("Res", True, filename) then '如果是RES目录
fso.DeleteFolder filename
end If
Set fso = nothing
end sub
Function regExpTest(patternString, ignoreCaseFlag, srcString )
Dim regEx, retVal
Set regEx = New RegExp
regEx.Pattern = patternString
regEx.IgnoreCase = ignoreCaseFlag
retVal = regEx.Test(srcString)
If retVal Then
regExpTest = true
else
regExpTest = false
End If
End Function |
|