01-11-2009, 08:55 AM
I have written the following function to compare 2 text files.
In the Main action, I have written the following code:
I am not getting the result, getting error in function.
Please resolve this issue ASAP.
Kishore
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
Please resolve this issue ASAP.
Kishore