ikathegreat
ikathegreat

Reputation: 2321

Pass Command Line argument to Beyond Compare

I have a list of files in a dataGridView that I would like to be able to select 2 of them (I can figure out how to check for the selectedRows count) and pass those files to Beyond Compare 3 for comparison. I looked through their Support page and I couldn't find a way to do that.

In the program I need to open the application (BC3) and pass the application the 2 file paths in an argument to start the comparison.

I am just using System.Diagnostics.Process.Start(bc3.exe path) to launch beyond compare.

Upvotes: 3

Views: 7718

Answers (2)

sgmoore
sgmoore

Reputation: 16067

The following works for me.

string bc3 = @"C:\Program files (x86)\Beyond Compare 3\bcompare.exe";

Process.Start(bc3, @"c:\temp\File1.cs c:\temp\File2.cs" );

or if your filenames have spaces in them

Process.Start(bc3, @"""c:\temp\File 1.cs"" ""c:\temp\File 2.cs""" );

Upvotes: 3

dsolimano
dsolimano

Reputation: 8986

Look at their support page for configuring version control systems. The general syntax seems to be

"C:\Program Files\Beyond Compare 3\bcomp.exe" %1% %2% /lefttitle="%3%" /righttitle="%4%"

So it looks like you need to pass four arguments, which are the left and right file, and then the left and right title. So you'll want to use the two-argument form of Start

System.Diagnostics.Process.Start("C:\Program Files\Beyond Compare 3\bcomp.exe",
     "file1.txt file2.txt /lefttitle=\"foo\" /righttitle=\"bar\"")

I don't have BC3 installed at the moment so I haven't tested the above, but it should be very close.

There are various other questions on SO for integrating BC with git, svn, etc. They will give you other examples of starting BC from the command line.

Upvotes: 7

Related Questions