Comparing Folders
Leave feedback
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.
- Instantiate the CompareOptions object.
- Set the
DirectoryCompareproperty totrue. - If needed, set the
setFolderComparisonExtensionproperty to change the output format toHTML. By default the format isTXT. - If needed, set the
ShowOnlyChangedproperty totrueto display only changed items. - Initialize the Comparer object. Specify the path to the first compared folder and the
CompareOptionsobject. - Call the Add method of the Comparer object. Specify a path to the second folder and the
CompareOptionsobject. - 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 HTML | Result in TXT |
|---|---|
![]() | ![]() |
Was this page helpful?
Any additional feedback you'd like to share with us?
Please tell us how we can improve this page.
Thank you for your feedback!
We value your opinion. Your feedback will help us improve our documentation.

