Welcome Serena Central users! CLICK HERE
The migration of the Serena Central community is currently underway. Be sure to read THIS MESSAGE to get your new login set up to access your account.
Highlighted
Absent Member.. vzamoraz Absent Member..
Absent Member..
280 views

QTP/UFT support tip: How to compare text files by code.

You can implement a samll function to compare the content of 2 text files:

 

Public Function CompareFiles(Path1, Path2)
   Dim fso,f1,f2,ts1,ts2
   Set fso = CreateObject("Scripting.FileSystemObject")
   Set f1 = fso.GetFile(Path1)
   Set f2 = fso.GetFile(Path2)
   Set ts1 = f1.OpenAsTextStream()
   Set ts2 = f2.OpenAsTextStream()
   If ts1.ReadAll = ts2.ReadAll Then
       CompareFiles = "Passed"
   Else
       CompareFiles = "Failed"
   End If
End Function




 

How to use this function?

try this:

 

msgbox CompareFiles ("D:\temp\hello.txt", "D:\temp\hola.txt") 

 

HP support

If you find this useful, mark Kudos.

 

Note: The Opinions expressed in my post are mine alone, and do not reflect the opinions of my employer. No warranties express or implied for any answered posted.

 

 

The example software is experimental and is provided as a courtesy, free of charge, "AS-IS" by Hewlett-Packard Development Company, L.P. ("HP"). HP shall have no obligation to maintain or support this software. HP MAKES NO EXPRESS OR IMPLIED WARRANTY OF ANY KIND REGARDING THIS SOFTWARE. HP SHALL NOT BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES, WHETHER BASED ON CONTRACT, TORT OR ANY OTHER LEGAL THEORY, IN CONNECTION WITH OR ARISING OUT OF THE FURNISHING, PERFORMANCE OR USE OF THIS SOFTWARE

 

Labels (1)
0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.