我正在使用vsDiffMerge.exe
自动执行文件比较功能,使用c#.net代码比较文件,但是当文件相同时,我需要从vsDiffMerge.exe到c#.net变量的输出信息,我正在使用下面的代码使用c#.net代码和vsDiffMerge.exe来跟踪Visual Studio位置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;
}
}