You can use Visual Studio to compare two files. Comparison of two files becomes easy when you have code in source control. However, for a regular comparison between two different files, we often look at different tools. Well, you can utilize the Visual Studio DiffFiles Tool for the same. It’s there with Visual Studio for long; however, it is often overlooked and many developers may unaware of this great tool. We can invoke this utility tool from Command Window. The Visual Studio Command Window is very powerful and can help you to execute things faster during development. The Command window can execute commands directly in the Visual Studio by using their names.
Launch the Command Window by navigating from View –> Other Windows –> Command Window.
The following screenshot shows a new command window open. The “>” indicates it is ready to accept commands.
Once you start typing here; you will find the available intellisene to select the commands faster. For an instance, as soon as I type file, I can see following list of command that are related with file.
Use Tools.DiffFiles command and provide both the FileNames as parameters and press enter. This will bring the comparison editors for the given files.
You can then leverage the Compare Files – Tools for different set of comparison along with navigating through the difference.
Following images show the inline mode of comparison for the selected files.
As said earlier, many of you may familiar with this utility, however this is something overlooked features of Visual Studio.
Give it a try if you haven’t.