How to suppress loading of the Beyond compare screen when using from windows formsapp

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Ganesh47
    Visitor
    • Apr 2015
    • 3

    How to suppress loading of the Beyond compare screen when using from windows formsapp

    Hi every one, I am using Beyond Compare 3 in my windows forms application using the arguments passing, I am able to compare the files. Every thing is working fine, but I am having some concerns like, I don't want to view the differences window for each and every file.

    As my requirement is I have some bunch of files in two folders (like ProdOutput and SITOutput) and I wanted to compare the differences for each file in both the folders (there is same file name in ProdOutput and SITOutput). I am using the below line of code for comparsion.

    //LaunchViewer method code which calls CompareFiles method
    string arguments = String.Format("\"{0}\" \"{1}\"", filepath1, filepath2);
    ProcessStartInfo psi = new ProcessStartInfo(ApplicationPath, arguments);
    using (Process p = Process.Start(psi))
    {
    ComparsionResult = CompareFiles(filepath1, filepath2);
    }

    //CompareFiles method code as below
    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;
    }
    }
    I am not sure what to do to suppress the launch but wanted to the comparison as normal.
    Any help highly appreciated.
  • Ganesh47
    Visitor
    • Apr 2015
    • 3

    #2
    Hi Aaron,

    I am having a similar situation like I wanted to the comparison but I dont want the user to view the differences or don't want give an access to close the window. All the comparison tasks should perform in silent mode.

    But my requirement is I am using in win forms application in .Net and I am reading all input files from different folders in a for loop and then am passing.

    FYI, I am pasting the code, but wanted to know how can I pass the "/silent" command line along with my piece of code.


    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;
    }
    complete thread can be found in Stack overflow http://stackoverflow.com/questions/2...90088_29873435

    Please do give a reply as earliest on the same.

    Comment

    • Aaron
      Team Scooter
      • Oct 2007
      • 16000

      #3
      Hello,

      For BC3 or BC4, using the /qc or /quickcompare command line with 2 files would generate a return code and not show the graphical interface. This only works with a pair of files and is not supported with folders. These do not have the /rules parameter, and use the default settings to determine the format.

      BC2 does not have /quickcompare or /qc, and instead uses bcqc.exe. You mention BC3, but posted in the BC2 forum, where /rules would exist but not with bcqc.exe.

      In either case, you'll want to simply the command line, remove the /rules declaration, and use the appropriate "bcqc.exe" or "bcomp.exe /qc" with two file names as the parameter. If you are having trouble, please try using this on the Windows Command Prompt outside of your scripting to see if it is working in a simpler test environment.
      Aaron P Scooter Software

      Comment

      • Ganesh47
        Visitor
        • Apr 2015
        • 3

        #4
        Resolved the issue with "/silent" option by passing along with the arguments

        First thing I am sorry that I have posted in BC2 where I am using BC3.

        Second thing the issue which I have posted for the query got resolved by a simple command line switch called "/silent" which I have passed as an argument along with my input files.

        This piece of code might helps to some one else, so I am posting down here.

        Code:
        ComparisonResult result = ComparisonResult.None;
        string arguments = String.Format("/quickcompare /rules=\"{0}\" \"{1}\" \"{2}\" /silent", ruleName, filepath1, filepath2);
        Originally posted by Aaron
        Hello,

        For BC3 or BC4, using the /qc or /quickcompare command line with 2 files would generate a return code and not show the graphical interface. This only works with a pair of files and is not supported with folders. These do not have the /rules parameter, and use the default settings to determine the format.

        BC2 does not have /quickcompare or /qc, and instead uses bcqc.exe. You mention BC3, but posted in the BC2 forum, where /rules would exist but not with bcqc.exe.

        In either case, you'll want to simply the command line, remove the /rules declaration, and use the appropriate "bcqc.exe" or "bcomp.exe /qc" with two file names as the parameter. If you are having trouble, please try using this on the Windows Command Prompt outside of your scripting to see if it is working in a simpler test environment.

        Comment

        • Aaron
          Team Scooter
          • Oct 2007
          • 16000

          #5
          /silent will suppress all output. It shouldn't be needed if you are using /quickcompare "file1" "file2" as the only parameters. As I also mentioned, you do not need /rules, since it is not a supported BC3 parameter.

          It is usually best to get a call working with feedback. Then, once it is known to be working as expected, add /silent as the last step to execute as part of the final workflow. If it's working for now, that's great; if you need to troubleshoot at all later, we'll need to remove /silent.
          Aaron P Scooter Software

          Comment

          Working...