Click here to Skip to main content
14,238,330 members
Rate this:
Please Sign up or sign in to vote.
See more:
My question is that I have to made a program in c# windows form that Compare two text files word by word and character by character on same indexes and highlight the difference in characters in third file.for example

file1.txt :

abc def
jkl mno
tha


file 2.txt :

ab ghi
pqr stu
the

and after comparison the third file shows the result as

abc def ghi
jkl pqr mno stu
thea

colour the words which shows that the word is deleted,or inserted.

OR

c is deleted in file 2.
def is deleted in file 2.
ghi is inserted.
jkl is deleted in file 2.
mno is deleted in file 2.
pqr is deleted in file 2.
stu is deleted in file 2.
a is deleted in file 2.
e is inserted in file 2.

I have search maximum c# code sites and codes but i think no one have done this yet in c# can any on help me or have that code the code should be simple that begainers also understand it please send it on my email id gakhar023@gmail.com and upload it for others thanks.
God bless you all.
Posted
Updated 8-Dec-12 11:13am
v4
Comments
CHill60 8-Dec-12 17:08pm
   
Please edit your question and remove your email - you will automatically get an email when someone answers your question
Rate this:
Please Sign up or sign in to vote.

Solution 1

It frequently gets set as an exercise so try one of the following ...
http://support.microsoft.com/kb/320348[^]
or
http://www.java2s.com/Code/CSharp/File-Stream/Comparetwofiles.htm[^]
   
Rate this:
Please Sign up or sign in to vote.

Solution 2

This is not a simple problem.

This article might be a good place to start: Difference Algorithm C#

Failing that trying searching on Google for, "file comparison algorithm c#" for alternatives.
Good luck.
   

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




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