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

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

@Muzna_Tariq,

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

@Muzna_Tariq,

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
docA.Save("C:\\temp\\21.5.docx");

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)

@Muzna_Tariq,

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.

The issues you have found earlier (filed as WORDSNET-22225) have been fixed in this Aspose.Words for .NET 22.12 update also available on NuGet.