Click here to Skip to main content
15,881,588 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi All,

I need to compare two files in C#.. If the files are same no need to display data. if the files are not same, and also need what are the differences in the file..
for example
string first = "this is the first content"

string second ="this is the second content"

if i compare these two string

It means i need 'Second' is the difference in the string...
Posted
Updated 16-Nov-11 3:33am
v2

Only plain String Comparison may not help you for what you are planning to achieve.

Below link has a information on how you can identify content of the Two Files is same or not.

http://support.microsoft.com/kb/320348

In case, if their is a difference in the content of the Files, then you will have to write custom algorithm to identify those differences.
 
Share this answer
 
v2
Comments
Sergey Alexandrovich Kryukov 16-Nov-11 14:28pm    
My 5. Last sentence is essential. Actually, there is no common universal definition of what to consider a "difference", it's a matter of definition.
--SA
RaisKazi 16-Nov-11 23:05pm    
Thank you SA.
RaviRanjanKr 16-Nov-11 14:47pm    
My 5+
RaisKazi 16-Nov-11 23:05pm    
Thank you Ravi.
Without shame, I link to my own article here on CP:

An LCS based diff-ing library in C#[^]
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 16-Nov-11 14:26pm    
A 5 without a shame :-)
--SA
Nish Nishant 16-Nov-11 14:28pm    
Thanks SA!
RaisKazi 16-Nov-11 23:07pm    
My 5. Thats a good article and should save a lot of time of OP.
 
Share this answer
 
v3
Comments
LanFanNinja 16-Nov-11 10:39am    
Three of the edits are my fault. I tried to fix your link twice before I realized the Treat my content as plain text, not as HTML check box was checked. Sorry :)

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