How to Compare password-protected files

Sometimes when working with documents you may need to get the result of a comparison of files in which one or even both files are password protected, and for this very case there is an option to compare files in spite of the fact that they are protected. This option allows you to compare protected files in any format where it is possible to set a password for the file.

The code sample to compare two password-protected files:

string sourcePath = @"source.format"; // NOTE: Path to the source document 
string targetPath = @"target.format"; // NOTE: Path to the target document 
string resultPath = @"result.format"; // NOTE: Path to the result document    

Options.LoadOptions loadOptionsSource = new Options.LoadOptions {Password = "passwordSource"}; // NOTE: options with password for the first file
Options.LoadOptions loadOptionsTarget = new Options.LoadOptions {Password = "passwordTarget"}; // NOTE: options with password for the second file
            
using (Comparer comparer = new Comparer(sourcePath, loadOptionsSource))
{
    comparer.Add(targetPath, loadOptionsTarget);
    CompareOptions compareOptions = new CompareOptions
   {
        DetectStyleChanges = true,
        DetalisationLevel = DetalisationLevel.High
   };
    comparer.Compare(resultPath, compareOptions);
}

As a result, we get the resulting comparison file of two password-protected files.

More resources

Advanced Usage Topics

To learn more about document comparison features, please refer to the advanced usage section.

GitHub Examples

You may easily run the code above and see the feature in action in our GitHub examples:

Free Online App

Along with full-featured .NET library we provide simple, but powerful free Apps.
You are welcome to compare your DOC or DOCX, XLS or XLSX, PPT or PPTX, PDF, EML, EMLX, MSG and other documents with free to use online GroupDocs Comparison App.

© Aspose Pty Ltd 2001-2022. All Rights Reserved.