File system object in QTP

By | July 8, 2009

File system object in QTP :

FSO stands for Files system object, during testing we need to do some basic task like add, move, copy, create and delete folders and files. We can also handle drives related things using File system object method.
So It is very much important to learn File system object.

I am going to give some basic examples which involves File system object, which are very much helpful for testing in QTP

Script to create and Delete folder:

Set fso = CreateObject(“Scripting.FileSystemObject”)

‘Following sentence used to create folder

Set fldr= fso.CreateFolder(“c:\qtp”)

‘Following sentence used to delete folder

Set fldr= fso.DeleteFolder(“c:\qtp”)

Script to know folder exist or not:

Set fso = CreateObject(“Scripting.FileSystemObject”)

Set fldrext = fso.FolderExists(“c:\qtp”)

‘If fldrext contains 1 than folder named qtp is exist.

Script to copy file and folder:

Set fso = CreateObject(“Scripting.FileSystemObject”)

‘Following sentence will copy file from qtp folder to qtp_learn folder.

Set cfile = fso.CopyFile “c:\qtp\” , “c:\qtp_learn\” , True

‘Following sentence will copy folder named qtp from “c:\” to “c:\qtp_learn” folder.

Set dfile = fso.CopyFolder “c:\qtp” , “c:\qtp_learn\” , True

So above are the basic and important examples which you may require frequently during testing in QTP.

Script to map and unmap network drive:
You can also map and unmap network drive using files system object using this link.

You will get lots of knowledge above handling network drive in above link.

You are always welcome to share your feedback on this post.

If you like this article, You can subscribe through mail.

One thought on “File system object in QTP

  1. sachin


    please, can you provide me help regarding FileSystemObject to save in sql server.


Leave a Reply

Your email address will not be published. Required fields are marked *