1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
| File2Compare "administrationcpio.txt","ciemecpio.txt"
Function File2Compare(File1,File2)
Const ForReading = 1, ForWriting = 2
Dim objFSO,objSourceFile,objSourceFile2
Titre ="Fichier à Comparer"
Dim bFileNotFound
bFileNotFound = False
Set objFSO = CreateObject("Scripting.FileSystemObject")
If Not objFSO.FileExists(File1) Then
MsgBox "Le Fichier N°1 n'existe pas, il faut choisir le Fichier N°1",VbExclamation,Titre
bFileNotFound = True
ElseIf Not objFSO.FileExists(File2) Then
MsgBox "Le Fichier N°2 n'existe pas, il faut choisir le Fichier N°2",VbExclamation,Titre
bFileNotFound = True
End If
If Not bFileNotFound Then
Set objSourceFile = objFSO.OpenTextFile(File1, ForReading) 'Fichier Original
Set objSourceFile2 = objFSO.OpenTextFile(File2, ForReading) 'Fichier Modifié
vrNumLigne = 0
vrNumLigne = vrNumLigne + 1
vrLigne = objSourceFile.ReadAll
Tab1 = Split(vrLigne," ")
vrLigne2 = objSourceFile2.ReadAll
Tab2 = Split(vrLigne2," ")
vrComprLign = StrComp(Tab1(0),Tab2(0), 1)
If vrComprLign = 1 Or vrComprLign = -1 Or IsNull(vrComprLign) Then
vrNul = "Le fichier n'a pas été modifié"
vrLignDif = vrLignDif & vrNumLigne & ": " & vrLigne & vbCrLf & vrNumLigne & ": " & vrLigne2 & vbCrLf & vbCrLf
End If
objSourceFile.Close
objSourceFile2.Close
If IsEmpty(vrNul) Then
MsgBox "Le fichier n'a pas été modifié ,les deux Fichiers sont identiques !",64,Titre
Else
'MsgBox vrLignDif,64,Titre
Dim fso, f
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.OpenTextFile("comparaison.txt", ForWriting,true)
f.WriteLine String(120,"*")
f.writeline "Résultat de la Comparison entre le fichier " & File1 & " et le fichier "& File2 & vbNewLine
f.WriteLine String(120,"*")
f.writeline(vrLignDif)
f.close
OpenLog("comparaison.txt")
End If
End If
End Function
Sub OpenLog(File)
Dim ws
Set ws = CreateObject("wscript.shell")
ws.run "Notepad " & File,1,False
Set ws = Nothing
End Sub |
Partager