I am automating the file compare feature using vsDiffMerge.exe
to compare the file using c#.net code that works fine but I need output information from vsDiffMerge.exe to c#.net variable when files are identical, I am using following code to compare the two files using c#.net code and vsDiffMerge.exe from following Visual Studio location C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\vsDiffMerge.exe
private void CompareFile()
{
bool isFileIdentical=false;
string exe = "C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\vsDiffMerge.exe";
string orignalSourceFile = _lstFiles[_selectedRowIndex - 1].SourceFilePath;
string orignalTargetFile = _lstFiles[_selectedRowIndex - 1].TargetFilePath;
string command = string.Format(@"""{0}"" ""{1}"" ""Source: {2}"" ""Target : {3}""{4}", sourceFile, targetFile,
orignalSourceFile,
orignalTargetFile,
chkOnlyOne.Checked ? "" : " /t");
var attr = File.GetAttributes(sourceFile);
File.SetAttributes(sourceFile, attr & ~FileAttributes.ReadOnly);
var attr2 = File.GetAttributes(targetFile);
File.SetAttributes(targetFile, attr2 & ~FileAttributes.ReadOnly);
ProcessStartInfo startInfo = new ProcessStartInfo();
startInfo.CreateNoWindow = false;
startInfo.UseShellExecute = false;
startInfo.RedirectStandardOutput = true;
startInfo.FileName = exe;
startInfo.WindowStyle = ProcessWindowStyle.Hidden;
startInfo.Arguments = command;
try
{
using (Process exeProcess = Process.Start(startInfo))
{
//string output = exeProcess.StandardOutput.ReadToEnd();
//isFileIdentical = exeProcess. ?
// I need output from exeProcess if both the files are identical
exeProcess.WaitForExit();
}
}
catch (Exception ex)
{
string e = ex.Message;
}
}