How To Check Whether Particular File and Folder Exists or Not in QTP?

QTP Script to check whether specified file and folder exist or not.

Data Driven Testing

Datatable Methods

Script to check particular text file exists or not.

Dim f1
Set f1 = CreateObject("Scripting.FileSystemObject")
If (f1.FileExists("D:\lakshmi.txt")) Then
Msgbox "file exists"
Else
Msgbox "file doesn't exist"
End If

FileExists Method:Returns True if a specified file exists,False if it does not.

Syntax:object.FileExists(filespec)

Above script checks text file("lakshmi")in D drive.
If text file is present "file exists" message is displayed else "file doesn't exist" message will be displayed.


Script to check particular folder exists or not.

Dim f1
Set f1 = CreateObject("Scripting.FileSystemObject")
If (f1.FolderExists("C:\laxmi")) Then
Msgbox "folder exists"
Else
Msgbox "folder doesn't exist"
End If

FolderExists Method:Returns True if a specified folder exists,False if it does not.

Syntax:object.FolderExists(folderspec)

Above script checks folder("laxmi")in C drive.
If folder is present "folder exists" message is displayed else "folder doesn't exist" message will be displayed.

SQL Queries Collection
Movie Songs Lyrics
How to Move a File From One Location to Another in QTP?
How to copy a file and folder from one location to other in QTP?
Export Database Data to ExcelSheet

No comments:

Related Posts Plugin for WordPress, Blogger...