Search code examples
c#winmerge

open winmerge with two documents side by side c#


I am developing a Windows Forms app in c# that will make changes to a document and I want to include a button that will open the before and after in winmerge.

If it is possible, how do I do it?

More Detail:

I want to click a button Show Result with the starting file in the textbox. It should open winmerge and open this dialog with the original file on the left and updated file on the right.

So far I have:

    Process notePad = new Process();
    notePad.StartInfo.FileName = "WinMerge.exe";
    notePad.StartInfo.Arguments = txtIn.Text;
    notePad.Start();

The updated file is in the same directory as the input file one level down in a folder called "UPDATED"


Solution

  • String leftFilePath = "...";
    String rightFilePath = "...";
    
    string exe = "winmergeu.exe";
    String args = $@"""{leftFilePath}"" ""{rightFilePath}""";
    
    Process.Start(exe, args);