winforms - How to suppress launching beyond compare 3 while doing a comparison from windows forms application -
i using beyond compare 3 in win forms application comparison in 2 output folders (prodoutput , sitoutput). using below lines of code doing comparison
public static void launchviewer(string filepath1, string filepath2) { string arguments = string.format("\"{0}\" \"{1}\"", filepath1, filepath2); processstartinfo psi = new processstartinfo(applicationpath, arguments); using (process p = process.start(psi)) { comparsionresult = comparefiles(filepath1, filepath2, beyondcomparerules.everythingelse); } } public static comparisonresult comparefiles(string filepath1, string filepath2, string rulename) { comparisonresult result = comparisonresult.none; string arguments = string.format("/quickcompare /rules=\"{0}\" \"{1}\" \"{2}\"", rulename, filepath1, filepath2); processstartinfo psi = new processstartinfo(applicationpath, arguments); psi.useshellexecute = false; psi.redirectstandardinput = true; psi.redirectstandardoutput = true; using (process p = process.start(psi)) { p.standardinput.writeline("exit [errorlevel]"); p.waitforexit(); int exitcode = p.exitcode; switch (exitcode) { case 0: result = comparisonresult.match; break; case 1: result = comparisonresult.similar; break; case 2: result = comparisonresult.donotmatch; break; case 3: result = comparisonresult.comparisonerror; break; default : result = comparisonresult.donotmatch; break; } } return result; }
beyond compare rules below
public sealed class beyondcomparerules { private beyondcomparerules() { } /// <summary> /// comparison rule set c/c++/c# source files /// </summary> public const string clanguagesource = "c/c++/c# source"; public const string cobol = "cobol"; public const string commaseparatedvalues = "comma separated values"; public const string delphisource = "delphi source"; public const string delphiforms = "delphi forms"; public const string generaltext = "general text"; public const string html = "html"; public const string java = "java"; public const string python = "python"; public const string registrydump = "registry dump"; public const string utf8text = "utf8 text"; public const string visualbasic = "visual basic"; public const string xml = "xml"; /// <summary> /// default set of comparison rules /// </summary> public const string everythingelse = "everything else"; }
and comparisonresult enum below
public enum comparisonresult { /// <summary> /// indicates null or uninitialized value /// </summary> none = 0, /// <summary> /// quick compare returned positive match /// </summary> match = 1, /// <summary> /// quick compare detected small differences /// </summary> similar = 2, /// <summary> /// quick compare detected significant differences /// </summary> donotmatch = 3, /// <summary> /// quick compare utility returned error/unknown result /// </summary> comparisonerror = 4 }
what need suppress launching beyond compare screen when doing comparison comparison should happen , should return result. above code able comparison , able view differences don't want do.
i guess there thing can passing arguments not sure , how , should put it.
any highly appreciated.
after several trials different ways achieve functionality, small piece of code did resolved issue.
there command line switches available beyond compare application needs passed when want suppress interactions. called "/silent".
i have passed along these lines in comparefiles method
public static comparisonresult comparefiles(string filepath1, string filepath2, string rulename)
comparisonresult result = comparisonresult.none; string arguments = string.format("/quickcompare /rules=\"{0}\" \"{1}\" \"{2}\" /silent", rulename, filepath1, filepath2);
all above posted code in question working fine , can used 1 wants suppress interactions.
Comments
Post a Comment