Micro Focus QTP (UFT) Forums
Reading an Existing File using FSO - 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: Reading an Existing File using FSO (/Thread-Reading-an-Existing-File-using-FSO)



Reading an Existing File using FSO - prabhu656656 - 09-09-2009

Hi,

I have a file from which I have to read. I have this file at C:\D & S\Users\...\XYZ.txt

I want this path to be assigned to an arugument "File_path" and I have to use "File_path" several times.

I have gone through FileSystemObject but there all the examples are Creating a file and then reading from it but here I already have a file that I have to read from..

I am trying to use this statement -
Code:
Set MyFile = CreateObject("scripting.FileSystemObject").OpenTextFile(file_path, ForReading)

Please guide me through as to how can I assign the file to "File_path"

Thank You.


RE: Reading an Existing File using FSO - sreekanth chilam - 09-10-2009

@Prabhu : try with the below ex.

For Reading the values from Textfiles :

Code:
Dim fso, ts
Const ForReading = 1
File_path="C:\D & S\Users\...\XYZ.txt"

Set fso = CreateObject("Scripting. FileSystemObject")
Set ts = fso.OpenTextFile(File_path,ForReading,True)
msgbox ts.ReadLine
ts.close