Release file handles after document comparison using C# in .NET

We are using GroupDoc to compare files, but when the comparison is completed and the output file is created, any attempt to open the file involved in the comparison results in a “File in use by another” exception. I have enclosed the comparison in a a use() block and I have tried to explicitly call the Dispose method. Neither will release the file handles of the file involved in the comparison.

Is there a way to force GroupDocs to release the file handles?

2 Likes

@johnhosier,

In order to investigate this issue at our end, following details are required:

  • API platform (.NET or Java)
  • API version (e.g. 19.7, 19.9)
  • Sample code using that issue could be reproduced
  • Problematic file

We are using the .NET API
The API version is
Runtime: v2.0.50727
Version: 19.9.0.0
The files being compared are simple docx files with a single line of text.
Here is our sample code where fullFilePath[] is a list of the files to compare::

//===========================================
using (var comparer = new Comparer(fullFilePath[0]))
{
for (int i = 1; i < fullFilePath.Count; i++)
{
comparer.Add(fullFilePath[i]);
}
var options = new GroupDocs.Comparison.Options.CompareOptions();
options.ShowDeletedContent = true;
options.ChangedItemStyle = new GroupDocs.Comparison.Options.StyleSettings()
{
IsStrikethrough = true,
IsUnderline = true,
HighlightColor = System.Drawing.Color.Purple,
IsBold = true
};

options.GenerateSummaryPage = true;

comparer.Compare(outputFilename, options);

resultFile = outputFilename;
error = null;

}
//===========================================

The output file of the comparison is fine. There are no issues with the output. The problem we are having is the files involved in the comparison cannot be opened after the comparison is complete. GroupDocs is not releasing the file handles.

1 Like

@johnhosier,

Thanks for the details. We have logged this scenario in our internal issue tracking system with ID: COMPARISONNET-2094. This is now under investigation. As there is any further update, you’ll be notified.

Thank you. I will wait for the update.

1 Like

@johnhosier,

You are welcome.

@johnhosier,

Your reported issue COMPARISONNET-2094 is now fixed in version 19.11.