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?
msgbox CompareFiles ("D:\temp\hello.txt", "D:\temp\hola.txt")
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