Click here to Skip to main content
12,405,543 members (62,727 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: C#3.5
hi friends,
I am developing a Comparison tool in C#. can anyone give me any idea to start with the comparison.

Task Details:

I am using C#2008. I want to compare two text files and wherever the diffrences in both the files it should be highlighted.

My work:

I am creating a windows application in c# where I am having two RichtextBoxes. I have loaded the file1 in 1st and file2 in 2nd Rich Text Box. Now I want to highlight the differences in RTB2 whereever It finds difference in first.

I have started with the comparison where
I am comparing line by line (1 line from RTB1 and 1 line from RTB2); but in this case my logic is being fail; because

1. If the number of lines differnces in both the files.
2. If lines moved from its position to another inside the same file.
3. If new lines inserted or deleted in 2nd RichTextBox; then it finds first difference
and highlighting that line but after that it is not matching any lines i.e. highligting each line as a difference in both the files. because of different number of lines.

NOTE : If anybody used Epsilon S/w.....then this s/w provides this type of functionality. here it is providing character by character comparison and currsor always stopped
when find differences in both files and showing the message "Difference Found". when again start comparision(Ctri+F2) then againg it shows next difference. and so on.......


I have searched over Internet but didn't find anything. There are some tools provided on internet but I can't use the tools because of some restriction ... so I have to develop my own. I have also searched for algorithm for this purpose but unable to find it.

Can anybody give me basic idea about how to start with this thing..... Please help me in this issue.

Thanks & Regards,
Adarsh.
Posted 19-May-10 19:22pm
Comments
Member 10846345 17-Jul-14 1:20am
   
hey I am facing the same problem could any one help me.
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

Maybe this can be of some help
  Permalink  
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 2

take 1st line word and made it characters and compare it with other character by character
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web01 | 2.8.160721.1 | Last Updated 5 Dec 2012
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100