We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Compare Text (.txt) Files using C# .NET & Save Results to Word Document

I want to compare two text files via Aspose Word nuget package. Can you please provide me with the sample code?


Yes, you can use Aspose.Words for .NET API to programmatically compare Text files (as well as many other supported file formats). Please refer to the following section of documentation:

The link does not contain code snippet for text documents. Please provide code snippet for comparing two text files


Please try the following C# code of Aspose.Words for .NET:

Document docA = new Document("C:\\temp\\A.txt");
Document docB = new Document("C:\\temp\\B.txt");
// DocA now contains changes as revisions. 
docA.Compare(docB, "user", DateTime.Now);
// Save to DOCX format

I tried above code with the attached two text files but it takes around 10 minutes to compare which is not acceptable. Please checktimeout.zip (198.4 KB)


For the sake of any corrections in Aspose.Words API, we have logged this problem in our issue tracking system with ID WORDSNET-22225. We will further look into the details of this problem and will keep you updated on the status of linked issue. We apologize for your inconvenience.