Monday, December 6, 2010

QTP -File System Scripts


1) Create a Folder

Option Explicit
Dim objFSO, objFolder, strDirectory
strDirectory = "D:\Gcreddy"
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.CreateFolder(strDirectory)



2) Delete a Folder                                       

Set oFSO = CreateObject("Scripting.FileSystemObject")
oFSO.DeleteFolder("E:\Gcreddy")



3) Copying Folders

Set oFSO=createobject("Scripting.Filesystemobject")
oFSO.CopyFolder "E:\gcr", "C:\jvr", True



4) Checking weather the folder available or not, if not creating the folder

Option Explicit
Dim objFSO, objFolder, strDirectory
strDirectory = "D:\Gcreddy"
Set objFSO = CreateObject("Scripting.FileSystemObject")
If objFSO.FolderExists(strDirectory) Then
Set objFolder = objFSO.GetFolder(strDirectory)
msgbox strDirectory & " already created "
else
Set objFolder = objFSO.CreateFolder(strDirectory)
end if



5) Returning a collection of Disk Drives

Set oFSO = CreateObject("Scripting.FileSystemObject")
Set colDrives = oFSO.Drives
For Each oDrive in colDrives
MsgBox "Drive letter: " & oDrive.DriveLetter
Next




6) Getting available space on a Disk Drive

Set oFSO = CreateObject("Scripting.FileSystemObject")
Set oDrive = oFSO.GetDrive("C:")
MsgBox "Available space: " & oDrive.AvailableSpace
 


The Confession: A Novel 
O Holy Night (CD/DVD) 

No comments:

Post a Comment