![](/uploads/1/2/5/5/125563957/535520911.jpg)
-->
![Folder compare utility windows 10 Folder compare utility windows 10](/uploads/1/2/5/5/125563957/525799235.png)
This example demonstrates three ways to compare two file listings:
Comparing Two Folders and its Subfolder batch file. You can be more specific for the file mask in the first folder if you want. For example folder1.txt. The command will report on files that exist in folder1 but are missing in folder2. Extra files in folder2 are simply ignored. There are a number of options to the FC command.
![Folders Folders](/uploads/1/2/5/5/125563957/926101217.jpg)
- By querying for a Boolean value that specifies whether the two file lists are identical.
- By querying for the intersection to retrieve the files that are in both folders.
- By querying for the set difference to retrieve the files that are in one folder but not the other.NoteThe techniques shown here can be adapted to compare sequences of objects of any type.
The
FileComparer
class shown here demonstrates how to use a custom comparer class together with the Standard Query Operators. The class is not intended for use in real-world scenarios. It just uses the name and length in bytes of each file to determine whether the contents of each folder are identical or not. In a real-world scenario, you should modify this comparer to perform a more rigorous equality check.Example
Compiling the Code
Create a C# console application project, with
using
directives for the System.Linq and System.IO namespaces.See also
![](/uploads/1/2/5/5/125563957/535520911.jpg)