Micro Focus QTP (UFT) Forums
FileHandling - Printable Version

+- Micro Focus QTP (UFT) Forums (https://www.learnqtp.com/forums)
+-- Forum: Micro Focus UFT (earlier known as QTP) (https://www.learnqtp.com/forums/Forum-Micro-Focus-UFT-earlier-known-as-QTP)
+--- Forum: UFT / QTP Beginners (https://www.learnqtp.com/forums/Forum-UFT-QTP-Beginners)
+--- Thread: FileHandling (/Thread-FileHandling)



FileHandling - Usha - 07-27-2008

Hi
I am a QTP beginner.
I wrote some code for file handling and I receive the error message saying "Invalid procedure call or argument" at line 8.
The code is below:
Code:
Dim fso1,file1,file1location
file1location = "c:\textfile.txt"
Set fso1 = createobject("scripting.filesystemobject")
Set file1 = fso1.createtextfile(file1location,true)
file1.write("This is Usha")
file1.write("Rani")
file1.close()
'The error is coming at the following line
Set file1 = fso1.opentextfile("c:\textfile.txt", ForReading, True)
Do while file1.AtEndOfStream<>true
    msgbox file1.readline()
Loop
Can anybody please help me?
Thank you


RE: FileHandling - gammaflare - 07-27-2008

Instead of ....
Code:
Set file1 = fso1.opentextfile("c:\textfile.txt", ForReading, True)

Try this.......
Code:
Set file1 = fso1.opentextfile("c:\textfile.txt",1, True)



RE: FileHandling - Usha - 07-28-2008

Hey
It worked.
Thank you so much for the reply.
Do you have any idea why it didn't take "For reading" argument..