Need to Compare Two Text Files

Hello All,

I have 2 different folders and both folders I have text format files. I need to compare both text files are same or not.

If my files are not same I need to get the value which contents are different in my files.

Could you please anyone help with this scenario? It’s a little urgent task.

Thanks in Advance.

Hi @yogavalli,

can you please give me some example files and output file, so that we can understand in better way.


Thank you for your immediate response @arivu96,

Can you please check the attached example files.Ex_2.txt (2.5 KB) Ex_1.txt (2.2 KB)

Hi @yogavalli,

Sorry for late response

I gone through the text file. Can you share the output file to how you are expecting.

Use read text file to read both text file

Use for each activity to loop the strText1 variable like below

If condition strText1.contains(item)
If no add it in separate variable.(strdiff)

So you can get the different


you could start by checking their sizes, that is faster, and then only when not you compare the text inside…

Interesting idea. How do you do that? Suggestions?


Hi, welcome to the community!
You can check the file size like this:

Dim myFile As New FileInfo("file.txt")
Dim sizeInBytes As Long = myFile.Length

can you please send the sample file?
how to compare the second file?
has some doubt in it

Req: Comparing 2 notepad files line by line. need to store the difference in both files in a separate file in notepad or in excel

2 IEnumerable item

  1. used FOR each activity for 1st file
  2. inside for loop created 2nd FOR loop
  3. if the loop compared the first and the second file
  4. if equals break the 2nd file for loop
  5. it breaks correctly but I couldn’t get the index of the broken line.
  6. I initialised the number var and counted for each line and and assign this num var to second forloop index.
  • issue facing is the index is not assign as the counted number. it is recreating to the first line
    so can u pls send me the sample file it will useful


Can you do this into the actual activity?