Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How do I compare 2 text files?
#2
Solved: 11 Years, 6 Months, 2 Weeks ago
Might be helpful to you.
Code:
Public Function CompareFiles (FilePath1, FilePath2)
Dim FS, File1, File2
Set FS = CreateObject(“Scripting.FileSystemObject”)

If FS.GetFile(FilePath1).Size <> FS.GetFile(FilePath2).Size Then
CompareFiles = True
Exit Function
End If
Set File1 = FS.GetFile(FilePath1).OpenAsTextStream(1, 0)
Set File2 = FS.GetFile(FilePath2).OpenAsTextStream(1, 0)

CompareFiles = False
Do While File1.AtEndOfStream = False
Str1 = File1.Read(1000)
Str2 = File2.Read(1000)

CompareFiles = StrComp(Str1, Str2, 0)

If CompareFiles <> 0 Then
CompareFiles = True
Exit Do
End If
Loop

File1.Close()
File2.Close()
End Function


Regards,
Sankalp
Reply


Messages In This Thread
How do I compare 2 text files? - by avanthika - 12-09-2011, 03:20 AM
RE: How do I compare 2 text files? - by sshukla12 - 12-09-2011, 11:08 AM
RE: How do I compare 2 text files? - by avanthika - 12-09-2011, 08:09 PM
RE: How do I compare 2 text files? - by Arul - 12-10-2011, 09:03 PM
RE: How do I compare 2 text files? - by avanthika - 12-10-2011, 08:49 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Need to Validate Text filed is blank after clicking on the Text box balak89 3 5,136 09-13-2015, 12:06 AM
Last Post: ADITI1992
  Compare WebTable Elements saraiado 1 2,634 06-11-2015, 06:54 PM
Last Post: venkatesh9032
  How to compare two binary values Naresh 0 2,441 09-09-2014, 05:06 PM
Last Post: Naresh
  Capture Value through Text Checkpoint and compare with datatable value hamzaz 2 4,930 03-06-2014, 12:52 AM
Last Post: mallika.g
  QTP Should open files(say txt files) it can be n number from a folder. Shiv Y 1 2,876 12-18-2013, 01:45 AM
Last Post: mlkrqtp

Forum Jump:


Users browsing this thread: 1 Guest(s)