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.
- Call the
setDirectoryCompare
method to set theDirectoryCompare
property totrue
. - If needed, call the
setFolderComparisonExtension
method to change the output format toHTML
. By default the format isTXT
. - If needed, call the
setShowOnlyChanged
method totrue
to display only changed items. - Initialize the Comparer object. Specify the path to the first compared folder and the
CompareOptions
object. - Call the add method of the Comparer object. Specify a path to the second folder and the
CompareOptions
object. - 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 folder1
and folder2
folders:
CompareOptions compareOptions = new CompareOptions();
compareOptions.setDirectoryCompare(true);
try (Comparer comparer = new Comparer("C:\\folder1\\", compareOptions)) {
comparer.add("C:\\folder2\\", compareOptions);
comparer.compare("C:\\res.html", 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.