Click here to Skip to main content
15,943,148 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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

file 2.txt :

ab ghi
pqr stu

and after comparison the third file shows the result as

abc def ghi
jkl pqr mno stu

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


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 and upload it for others thanks.
God bless you all.
Updated 8-Dec-12 11:13am
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

It frequently gets set as an exercise so try one of the following ...[^]
Share this answer
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.
Share this answer

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

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900