how to compare 2 files using two RichTxtBox

please can you help me giving sample codes..

thanks.. i'll wait.




Answer this question

how to compare 2 files using two RichTxtBox

  • FlorinB

    how to put number lines on textbox

  • Vidhya

    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.



  • ManuKarthink

    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.



  • pweyzen1

    using a path.. then it will be putted in the textboxes. If the button is clicked, it will highlight the differences.

  • Ecrofirt

    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);




  • TahoePete

    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.

  • DarrenSQLIS

    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



  • yhong

    can you give me a sample code

  • piotrfe

    *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.



  • Vinzcenzo

    maybe how about comparing the lines in both textboxesm, not the string.



  • ERK33136

    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.



  • JaysonM

    can you give me some ideas

  • Sergey Galich

    thanks..

  • iparkin

    how about TextBox only..

    yes.. i want a code to compare two textfiles.



  • how to compare 2 files using two RichTxtBox