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

Hi,

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")
file_path="C:\UFTVBFile.txt"
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.")
   MyFile.Close
End Sub

 

Please advise.

Ankush Thakur

 


A
Ankush Replied on 27/11/2020

Responsive image


A
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