Create a Main Folder,SubFolder in UFT and ZipAttachment to QC test

Function CreateMainFolder()
On Error Resume Next

'Dim strDrive, strfoldername,objFSO, objFolder

strDrive = "K:\QA\"

strfoldername="Automation_Results"

strPath= strDrive&strfoldername

Set FSO = CreateObject("Scripting.FileSystemObject")
Check = FSO.FolderExists(strPath)
Set FSO = Nothing
If Not Check Then

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.CreateFolder(strPath)

End If

End Function

Function CreateSubFolder(strPath)
On Error Resume Next

'Dim  strSubFile,objFSO, objFolder

''strSubFile = "Production_Result_"& Day(now) & "_" & month(now) & "_" & year(now) & "_"& hour(now) & "_" & minute(now)
''strNewpath=strPath& "\"&strSubFile

Set FSO = CreateObject("Scripting.FileSystemObject")
Check = FSO.FolderExists(strNewpath)
Set FSO = Nothing
If Not Check Then

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.CreateFolder(strNewpath)
End If

StrReportname= gbReportFilePath & "\TestResult_" & Day(now) & "_" & month(now) & "_" & year(now) & "_" & hour(now) & "_" & minute(now) &".html"

End Function

Function ZipAttachment(strNewpath)
On error resume next
      ZipAttachments = ""

    ' Declare the required variables
    Dim objZip, objSA, objFolder, zipFile, FolderToZip
    
    zipFile = strNewpath & ".zip"
    FolderToZip = strNewpath

    'Create the basis of a zip file.
    CreateObject("Scripting.FileSystemObject") _
    .CreateTextFile(zipFile, True) _
    .Write "PK" & Chr(5) & Chr(6) & String(18, vbNullChar)

    ' Create the object of the Shell
    Set objSA = CreateObject("Shell.Application") 
    
    ' Add the folder to the Zip
    Set objZip = objSA.NameSpace(zipFile) 
    Set objFolder = objSA.NameSpace(FolderToZip) 
    objZip.CopyHere(objFolder.Items) 
    
    ZipAttachments = zipFile
    
    'return ZipAttachment

End function

Comments

Popular posts from this blog

UFT File Types and File Extensions

QTP/UFT Version History

Synchronization in UFT