FileSystemObject - CreateTextFile method | QTP/UFT Forum
Ankush Posted on 27/11/2020


I on the Module 5, and I am unable to create a text file with the provided code, the test case is being passed, however the txt file is not being created. 


I have used the following code in my script.

1) First code

Set fso = CreateObject("Scripting.FileSystemObject")
fso.CreateTextFile file_path


2) Second code

Sub CreateAfile
   Dim fso, MyFile
   Set fso = CreateObject("Scripting.FileSystemObject")
   Set MyFile = fso.CreateTextFile("c:\testfile.txt", True)
   MyFile.WriteLine("This is a test.")
End Sub


Please advise.

Ankush Thakur


Ankush Replied on 27/11/2020

Responsive image

Ashish Thakur Replied on 03/12/2020

Sorry for delay

It should be

Set fso = CreateObject(“Scripting.FileSystemObject”)
Set file = fso.CreateTextFile(file_location, True)

file_location - location if file