Comparing Folders

View as MarkdownMarkdown

Set up your AI agent

Give your coding agent live access to the GroupDocs documentation and API reference through the GroupDocs Docs MCP server — no install, no API key. Learn more

claude mcp add --transport http groupdocs-docs https://docs.groupdocs.com/mcp

Also process documents locally

The GroupDocs.Comparison MCP server lets your agent work with files on your machine; they are never uploaded. It needs the .NET 10 SDK or Docker.

claude mcp add groupdocs-comparison -- dnx GroupDocs.Comparison.Mcp --yes
Folders, licensing and more →

On this page

GroupDocs.Comparison allows you to compare the contents of a folder (directory), process and save the result of processing. The steps for starting the comparison and configuring the display of the processing result in the resulting file are described below.

  1. Instantiate the CompareOptions object.
  2. Set the DirectoryCompare property to true.
  3. If needed, set the setFolderComparisonExtension property to change the output format to HTML. By default the format is TXT.
  4. If needed, set theShowOnlyChanged property to true to display only changed items.
  5. Initialize the Comparer object. Specify the path to the first compared folder and the CompareOptions object.
  6. Call the Add method of the Comparer object. Specify a path to the second folder and the CompareOptions object.
  7. Call the Compare method of the Comparer object. Specify a path to save the compare results and the CompareOptions object.

The following code snippet shows how to compare the SourceFolder and TargetFolder folders:

using System;
using GroupDocs.Comparison;
using GroupDocs.Comparison.Options;
class YoursProgram
{
    static void Main(string[] args)
    {
        CompareOptions compareOptions = new CompareOptions
        {
            DirectoryCompare = true,
        };
        Comparer comparer = new Comparer("C:\\SourceFolder", compareOptions);
        comparer.Add("C:\\TargetFolder", compareOptions);
        comparer.Compare("C:\\Folder_to_save_result\\", compareOptions);
    }
}

The following images show the comparison result:

Result in HTMLResult in TXT

See also

On this page