Skip to content

File Comparison logic

Nithya Mohanraj

Asked Feb 4, 2010, 4:24 AM EST1 answer
Share
LinkedInX
Hi,

Anyone know the file comparison logic.

In c# windows application, in the form, i have two combobox. let us consider leftcombobox and rightcombobox.  (It contains the file path C:\abc.txt)

Below that I have two richtextbox, for eg, leftRichTextbox and rightRichTextbox.

Combobox contains filename. If I have selected one file, the file content should display in the respective richtextbox.

Here I want to compare both the file content. If there is any difference, I need to differentiate it while displaying the content. By changing color or make it as bold something like that.

For eg:

ComboBox             c:\abc.txt                                                  c:\xyz.txt
LineNo   Content of LeftRichTextbox                              Content of RightRichTextbox

      1       This is a sample file in left                                  Hi
      2       LeftRichTextbox                                                 Hello
      3                                                                                 This is a sample file in right
      4      Thanks To All                                                       RightRichTextBox
      5      IN CAPS                                                               in caps                                     6      Bye All                                                                 Thanks


Result :

LNo       LeftRichTextBox                                                  RightRichTextBox
1                                                                                       Hi
2                                                                                       Hello
3        This is the sample file in left                                 This is the sample file in right
4        LeftRichTextbox                                                    RightRichTextBox
5
6        Thanks To All
7        IN CAPS                                                                in caps
8        Bye All
9                                                                                     Thanks

Note: In Result, in lineNo.5, in the LeftRichTextBox it should display the empty line in different color. (I want to differentiate the empty line also)

I need the file comparison logic.

If anyone knows the logic in some other language like 'C', kindly send me the link.

Thanks.

1 Answer

Know the answer? Post it. Somebody with the same question will find it here.

  • 0
    Hi,

    Alignment is not clear in the previous post. Sorry for that.

    ComboBox             c:\abc.txt                                                  c:\xyz.txt
    LineNo   Content of LeftRichTextbox        Content of RightRichTextbox

          1       sample file in left                           Hi
          2       LeftRichTextbox                           Hello
          3                                                           sample file in right
          4      Thanks To All                                RightRichTextBox
          5      IN CAPS                                       in caps   
          6      Bye All                                           Thanks

    Result :

    LNo       LeftRichTextBox                              RightRichTextBox
    1                                                                        Hi
    2                                                                        Hello
    3        sample file in left                                       sample file in right
    4        LeftRichTextbox                                      RightRichTextBox
    5
    6       
    Thanks To All
    7
            IN CAPS                                                 in caps
    8        Bye All
    9                                                                       
    Thanks

    I hope it will display correctly this time.

    Thanks.
    0