The code I posted will tell you if they are different. Then the problem is, when you walk the strings and find a difference, you need to then step through both strings, trying to work out which has the extra text, or if both are containing unique strings and they are the same again further on.
OK - that's a totally different question. You do need a richtextbox for this, because you want to show highlighting. This is a nontrivial problem and I'd be astounded if anyone wrote a diffing routine for you and posted it here.
You can split the string into an array of lines if you like, but that's not the way to go, and it doesn't solve any of the problem. You still don't know when you hit a difference if the two files are totally different from that point, if the first file has some extra info, if the second has some extra info, or if both have different info and then become the same again later on.
What do you want to do Are the two files text only files Why do you want to use a richtextbox Do you want the code to compare the files, or the user If the code, why use rich text boxes
how to compare 2 files using two RichTxtBox
cwestervelt
Radwanh
maybe how about comparing the lines in both textboxesm, not the string.
Bruce
So what do the textboxes do Do they show the text, or just allow path input
And ( again ), are these files text only
TextReader tr1 = new StreamReader(path1);
TextReader tr2 = new StreamReader(path2);
string s1 = tr1.ReadToEnd();
string s2 = tr2.ReadToEnd();
bool areTheSame = (s1 == s2);
ben5173
Robert135
cristianin
OK - that's a totally different question. You do need a richtextbox for this, because you want to show highlighting. This is a nontrivial problem and I'd be astounded if anyone wrote a diffing routine for you and posted it here.
Skip_Frog
Either add them to the string, or write a custom control that renders line numbers to the left of the actual text being rendered. I'd go for option 2.
amcoop
You can split the string into an array of lines if you like, but that's not the way to go, and it doesn't solve any of the problem. You still don't know when you hit a difference if the two files are totally different from that point, if the first file has some extra info, if the second has some extra info, or if both have different info and then become the same again later on.
mbaird
RickLH
Miha Stajdohar
What do you want to do Are the two files text only files Why do you want to use a richtextbox Do you want the code to compare the files, or the user If the code, why use rich text boxes
rhfritz
how about TextBox only..
yes.. i want a code to compare two textfiles.
jagdeep singh
*sigh* To reiterate:
This is a nontrivial problem and I'd be astounded if anyone wrote a diffing routine for you and posted it here.
Trevor Clark