Visual Basic Compare Documents

Greetings,

 I am looking to compare documents to output the differences between them in Visual Basic. Looking for an add-on with clear directions on use and examples. What I am currently using is ok to compare, but if their is one word different then the detection is worthless.

Private Function FileCompare(ByVal file1 As String, ByVal file2 As String) As Boolean
        Dim file1byte As Integer
        Dim file2byte As Integer
        Dim fs1 As FileStream
        Dim fs2 As FileStream

        If (file1 = file2) Then
            Return True
        End If

        fs1 = New FileStream(file1, FileMode.Open)
        fs2 = New FileStream(file2, FileMode.Open)

        If (fs1.Length <> fs2.Length) Then
            fs1.Close()
            fs2.Close()
            Return False
        End If

        Do
            file1byte = fs1.ReadByte()
            file2byte = fs2.ReadByte()
        Loop While ((file1byte = file2byte) And (file1byte <> -1))

        fs1.Close()
        fs2.Close()

        Return ((file1byte - file2byte) = 0)
    End Function

Open in new window

LVL 1
-GeekAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

aikimarkCommented:
1. Are these text/document type files or binary data?
2. How will the output of this function be used?
0
-GeekAuthor Commented:
These are word documents, the Microsoft comparison above is a byte by byte I believe.
0
aikimarkCommented:
Do your users have Word on their systems?  If so, why not use Word's document comparison functionality?
0
HTML5 and CSS3 Fundamentals

Build a website from the ground up by first learning the fundamentals of HTML5 and CSS3, the two popular programming languages used to present content online. HTML deals with fonts, colors, graphics, and hyperlinks, while CSS describes how HTML elements are to be displayed.

-GeekAuthor Commented:
They don't I had thought about that already.
0
aikimarkCommented:
If the users do not have Word on their PCs, then why are they trying to compare their contents?!?

Have you looked at the Open Office SDK?  I know that it allows your VB.Net program to work with documents, especially the .docx format.  That will be helpful in parsing the contents of the documents.

I would recommend looking at some libraries or utilities that do document comparison and see if you might be able to launch them from your application and then present the results.

Is it possible to use these two documents as parameters to a web service call?  Maybe you can install Word on your server.
0
-GeekAuthor Commented:
Didn't think if that, do you have any links?
0
aikimarkCommented:
Here is the download page for the Open XML SDK v2.5.  According to the text in the Details section, document comparison is a feature in the SDK.
http://www.microsoft.com/en-us/download/details.aspx?id=30425

This is probably a good starting point for understanding the SDK
http://msdn.microsoft.com/en-us/library/office/bb448854.aspx
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
-GeekAuthor Commented:
I have about 7 - 10 documents to compare to 1, and most I found for that are in c#. Do you know of any examples in VB that I could utilize? Looks promising.
0
aikimarkCommented:
do it manually.  For that few documents, you shouldn't expend any of your time coding.
0
-GeekAuthor Commented:
7 - 10 at a time, it spans in the upwards of sometimes 30 documents, and this is by 5 individuals so it's quite a large task ( 5 x 30 ). Sorry for not being clear enough. I am looking to add more folks to the document pool so currently at 5 but don't want to add more until I can nail this task.
0
-GeekAuthor Commented:
Thank you very much, will open further questions around findings.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.