Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Please resolve this issue in comparing 2 text files
#1
Not Solved
I have written the following function to compare 2 text files.

Code:
Public Function CompareFiles2 (FilePath1, FilePath2)
Dim FS, File1, File2
Set FSO = CreateObject("Scripting.FileSystemObject")

If FSO.GetFile(FilePath1).Size <> FSO.GetFile(FilePath2).Size Then
CompareFiles2 = True
Exit Function
End If

Set File1 = FSO.GetFile(FilePath1).OpenAsTextStream(1, 0)
Set File2 = FSO.GetFile(FilePath2).OpenAsTextStream(1, 0)

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

CompareFiles2 = StrComp(Str1, Str2, 0)

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

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

In the Main action, I have written the following code:

Code:
FilePath1="C:\Temp\" & DataTable("FileName",dtGlobalSheet) & "_" & DataTable("GLang",dtGlobalSheet) & "_" & "privacy" & "_" & "Actual" & ".txt"
FilePath2= "C:\Temp\" & DataTable("FileName",dtGlobalSheet) & "_" & DataTable("GLang",dtGlobalSheet) & "_" & "termsandprivacy" & ".txt"

If CompareFiles2(FilePath1,FilePath2) = False Then
Reporter.ReportEvent micPass, "Files are same","Passed"
Else
Reporter.ReportEvent micFail, "Files are different","Fail"
End If
I am not getting the result, getting error in function.

Please resolve this issue ASAP.
Kishore
Reply


Messages In This Thread
Please resolve this issue in comparing 2 text files - by kkishore12345 - 01-11-2009, 08:55 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Need to Validate Text filed is blank after clicking on the Text box balak89 3 4,556 09-13-2015, 12:06 AM
Last Post: ADITI1992
  UFT taking different script execution timings while comparing 2 excel files. sudheer 0 2,224 06-26-2015, 03:28 PM
Last Post: sudheer
  how resolve "webedit" cannot identify jabap4 3 4,306 04-23-2015, 08:22 PM
Last Post: babu123
  Comparing webtable data with weblist and webelements in other webpage arnav 1 5,602 04-18-2014, 10:01 PM
Last Post: Parke
  Comparing two excel Sheets whose columns names vary Divya Roopa 2 8,302 03-26-2014, 07:20 PM
Last Post: Parke

Forum Jump:


Users browsing this thread: 1 Guest(s)