Micro Focus QTP (UFT) Forums
FSO Error - 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: FSO Error (/Thread-FSO-Error)



FSO Error - newqtp - 04-29-2008

Hi All,
I've creating a text file and then trying to open that file for writing text into it but i'm getting error invalid procedure call.

Code:
Set fso=createobject("Scripting.FileSystemObject")
Set CFile=fso.createtextfile("c:\test.txt",true)
Set ofile=fso.opentextfile("c:\test.txt",forwriting,true) 'Here i'm getting
'error I've that file on my C drive I've tried Cfile.OpenTextFile
'Combination but that also not working
ofile.write("this is sample test data")&vbcrtl
ofile.write("making sure I've entered")

Thanks.


RE: FSO Error - newqtp - 04-29-2008

used OpenAsTextStream(2, TristateUseDefault) 'forwriting default value is 2 and forreading default value is 1.
Now code will look like
Code:
set fso=createobject("scripting.FileSystemObject")
set f= fso.getfile(c:\test.txt")
set ofile=f.OpenAsTextStream(2, TristateUseDefault)
ofile.write "this is test" & Vbcrlf

But i want to try opentextfile command. Plz help on that.
Thanks


RE: FSO Error - somisays - 04-29-2008

Hi,
Your code is right ,but if you use 2 instead of for writing then it is going to wrokout.

Use these values then you will get it.
Forwriting --- 2
ForAppending--- 8
ForReading .... 1


Code:
Set fso=createobject("Scripting.FileSystemObject")
'Set CFile=fso.createtextfile("c:\test.txt",true)
Set ofile = fso.OpenTextFile("c:\\test.txt", 2, True)
ofile.write "this is sample test data"
ofile.write "making sure I've entered"
ofile.close

Regards
Sridhar


RE: FSO Error - newqtp - 04-29-2008

Thanks Sridhar..