Automation: QTP tutorial – Function to add a new directory folder

Hi. Today, we have a simple and easy to use function to add a folder to a specific directory.

Call the function like in the example below:

1. For the first argument, enter a folder path where you want to create a directory

2. For the second argument, enter the folder name

3. Run the script and you should see the "NewTestFolder" in your C directory


 

 

 

Call function:

funAddNewFolder "C:/", "NewTestFolder"


Function code:
Function funAddNewFolder(path, folderName)
Dim  f, fc, nf
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.GetFolder(path)
Set fc = f.SubFolders
fc.Add(folderName)
set fso=nothing
End Function

 

Please leave comments and questions below!

Pin It on Pinterest

Clef two-factor authentication