anurag anurag - 3 months ago 21
C# Question

How to save compare reports generated by beyond compare programatically

I have a piece of code where I am comparing two files using Beyond compare .

string s = @""C:\Program Files\Beyond Compare 2\BC2.exe"";

Process.Start(s, @"c:\temp\File1.txt c:\temp\File2.txt" );


Now i want to save the Compare report with a filename and at a locationon my desktop programatically.

I searched the documents but could not find anything on saving the reports.

Currently the above code execution opens a window as is visible in the image
(don't get confused with the black part on the window, i have colored it that way to hide file locations)
don't get confused with the black part on the window, i have colored it that way to hide file locations

Thanks in advance.

Answer

I found the solution on documentation page of Beyond compare.

Add the following lines in file and save it with My Script.txt

file-report layout:side-by-side &
options:ignore-unimportant,display-context &
output-to:%3 output-options:html-color %1 %2

Now using command prompt run the following code BeyondCompate.exe @"My Script.txt" "1.txt" "2.txt" "Save.html" This will save the report in Save.html.

I incorporated this in my code as :

System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo();
startInfo.FileName = "cmd.exe" ;
startInfo.Arguments = "/c" + "BeyondCompare.exe" + " " + @"My Script.txt" + " " + "1.txt" + " " + "2.txt" + " " +"Save.html";
System.Diagnostics.Process.Start(startInfo);
Comments