How to compare the text in two files using c#?
-
Consider that there are two files named file1.txt and file2.txt. file1.txt consists 50lines file2.txt consists 50lines Now I want to compare the text of two files taht to line by line, I mean How can I compare 1st line of file1.txt with 1st line of file2.txt similarly 2nd line of file1.txt with 2nd line of file2.txt, etc., till the last line
-
Consider that there are two files named file1.txt and file2.txt. file1.txt consists 50lines file2.txt consists 50lines Now I want to compare the text of two files taht to line by line, I mean How can I compare 1st line of file1.txt with 1st line of file2.txt similarly 2nd line of file1.txt with 2nd line of file2.txt, etc., till the last line
-
Consider that there are two files named file1.txt and file2.txt. file1.txt consists 50lines file2.txt consists 50lines Now I want to compare the text of two files taht to line by line, I mean How can I compare 1st line of file1.txt with 1st line of file2.txt similarly 2nd line of file1.txt with 2nd line of file2.txt, etc., till the last line
You have to use StreamReader Suppose you have Two streamreader objects sr1 and sr2 while((str1=sr1.ReadLine())!="" &&(str2=sr2.ReadLine())) { if(str1!=str2) //The Files Are different... }
Vinod Kumar Prajapati Software Engineer EBC Publishing Pvt. Ltd.