File System Object in UFT

The File System Object (FSO) object model provides an easy object-based model for working with folders and files. The FSO object exposes a comprehensive set of properties and methods to perform various file system operations such as reading, writing, creating, moving, deleting, and providing information about folders and files.

File System Object FSO in UFT VBA myskillpoint

In UFT/QTP FSO Object significantly used to perform the following operations using simple VBScript (VBA)

  • Read and Write/Update a Plain Text file (notepad)
  • Creating a directory
  • Check whether a directory exists in the specified path
  • Create a file
  • Check whether a file exists in the required path
  • Delete a File
  • Delete a Directory

File System Object in VBScript – Read a Text File

File System Object in UFT – Get Entire Text of a File in a Variable

File System Object – Append Text in an Existing File

File System Object – Create or Open an Existing File and Append Text

The below code will check whether the provided file exists. If the file exists it will open the file and write the required text. If the file does not exist, it will create the required file and write the required text in it.

File System Object – Open an Existing File and Overwrite it

File System Object – Create a Text file and Write Text in it

Check Whether a File Exists Using File System Object 

Check Whether a Folder Exists Using File System Object 

File System Object – Create a Folder if it does not Exist

Delete a File Using File Using System Object VBScript in UFT

Delete a Folder Using File System Object VBScript in UFT

Recommended Posts

Leave a Reply