08-26-2010, 02:57 AM
Hi I get "Invalid call or procedure error" when I run the below script. Can you pls help me fixing it? thx.
error line : If FS.GetFile(Path1).Size <> FS.GetFile(Path2).Size Then
'''''''''''''''complete script'''''''''''''''''
error line : If FS.GetFile(Path1).Size <> FS.GetFile(Path2).Size Then
'''''''''''''''complete script'''''''''''''''''
Code:
Public function CompareFiles(Path1, Path2)
Dim FS, FirstFile, SecondFile
Set FS = CreateObject ("Scripting.FileSystemObject")
If FS.GetFile(Path1).Size <> FS.GetFile(Path2).Size Then
CompareFiles = True
Exit Function
End If
Set FirstFile = FS.GetFile(Path1).OpenAsTextStream(1,0)
Set SecondFile = FS.GetFile(Path2).OpenAsTextStream(1,0)
CompareFiles = False
Do while FirstFile.AtEndOfStream = False
Str1 = FirstFile.Read(1000)
Str2 = SecondFile.Read(1000)
CompareFiles = StrComp(Str1, Str2, 0)
If CompareFiles <> 0 Then
CompareFiles = True
Exit Do
End If
Loop
FirstFile.Close()
SecondFile.Close()
End Function
File1 = Inputbox("Enter directory for first file ")
File1 = Inputbox("Enter directory for seconf file ")
If CompareFiles(File1, File2) = False Then
Msgbox File1 & " " &File2 &" are same"
else
Msgbox File1 & " " &File2 &" are not same."
End If