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. Call the setDirectoryCompare method to set the DirectoryCompare property to true.
  3. If needed, call the setFolderComparisonExtension method to change the output format to HTML. By default the format is TXT.
  4. If needed, call thesetShowOnlyChanged method 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:


// ...
import com.groupdocs.comparison.Comparer;
import com.groupdocs.comparison.options.CompareOptions;
CompareOptions compareOptions = new CompareOptions();
compareOptions.setDirectoryCompare(true);
try (Comparer comparer = new Comparer("C:\\SourceFolder\\", compareOptions)) {
    comparer.add("C:\\TargetFolder\\", compareOptions);
    comparer.compare("C:\\result.html", compareOptions);
}

The following images show the comparison result:

Result in HTMLResult in TXT

On this page