29-11-21 11:54 AM
Hello!
I want to compare 2 word documents and check if there are differences between them, using C# or VB.net
Could you please help me giving some suggestions?
Thanks
29-11-21 01:57 PM
' Inputs: [File 1], [File 2]
' Outputs: [Files Match]
Dim File1Size As Integer = new FileInfo(File_1).Length
Dim File2Size As Integer = new FileInfo(File_2).Length
If File1Size <> File2Size Then
Files_Match = False
Return
End If
Using FS1 As New FileStream(File_1, FileMode.Open)
Using FS2 As New FileStream(File_2, FileMode.Open)
Dim File1Buffer(4096) As Byte
Dim File2Buffer(4096) As Byte
Dim File1Bytes As Integer = 0
Dim File2Bytes As Integer = 0
Do
File1Bytes = FS1.Read(File1Buffer, 0, 4096)
File2Bytes = FS2.Read(File2Buffer, 0, 4096)
For Index As Integer = 0 To File1Bytes - 1
If File1Buffer(Index) <> File2Buffer(Index) Then
Files_Match = False
Return
End If
Next Index
Loop While File1Bytes <> 0
End Using
End Using
Files_Match = True