Interview Questions   Tutorials   Discussions   Programs   Videos   

QTP - Explain about the File System Object in QTP with example?




266
views
asked marvit August 30, 2014 03:13 AM  

Explain about the File System Object in QTP with example?


           

1 Answers



 
answered By Dharma   0  
Dim fso, d

Set fso = CreateObject("Scripting.FileSystemObject")

Set d = fso.GetDrive(fso.GetDriveName(drvPath))

'Volume Name

msgbox d.VolumeName

'The total size of the drive in bytes (TotalSize property)

msgbox "Total Space: " & FormatNumber(drv.TotalSize / 1024, 0)

'How much space is available on the drive in bytes (AvailableSpace or FreeSpace properties)

msgbox "Available Space: " & FormatNumber(d.AvailableSpace/1024, 0)

'What letter is assigned to the drive (DriveLetter property)

msgbox "Drive " & d.DriveLetter

'What type of drive it is, such as removable, fixed, network, CD-ROM, or RAM disk (DriveType property)

'0:"Unknown"

'1:"Removable"

'2:"Fixed"

'3:"Network"

'4:"CD-ROM"

'5:"RAM Disk"

msgbox d.DriveType

'The drive's serial number (SerialNumber property)

msgbox d.SerialNumber

'********************************************************************************

'******************************Workin g with Folders*********************************

'********************************************************************************

'Create Folder

CreateObject("scripting.filesystemobject").CreateFolder(FolderPath)

'Delete Folder

CreateObject("scripting.filesystemobject").DeleteFolder(FolderPath)

'Move Folder

CreateObject("scripting.filesystemobject").MoveFolder SourceFolderPath,DestinationFolderPath

'Copy Folder

CreateObject("scripting.filesystemobject").CopyFolder SourceFolderPath,DestinationFolderPath

'Get Name of a Folder

msgbox CreateObject("scripting.filesystemobject").GetFolder(FolderPath).Name

'Check for Folder Existance

msgbox CreateObject("scripting.filesystemobject").FolderExists(FolderPath)

'Get Parent Folder Name

msgbox CreateObject("scripting.filesystemobject").GetFolder(FolderPath).ParentFolder.Name

'Get Sub Folders from a Folder

Dim fso,fld,sfolders,sFld

Set fso = CreateObject("Scripting.FileSystemObject")

Set fld = fso.GetFolder(FolderPath)

Set sfolders = fld.SubFolders

For Each sFld in sfolders

msgbox sFld.name

Next

'Get Files From a Folder
flag   
   add comment

Your answer

Join with account you already have

FF

Preview


Ready to start your tutorial with us? That's great! Send us an email and we will get back to you as soon as possible!

Alert