更新中...
我想从Console应用程序调用kdiff。所以我正在构建两个文件,并希望在执行我的程序时比较它们:
string diffCmd = string.Format("{0} {1}", Logging.FileNames[0], Logging.FileNames[1]);
// diffCmd = D:\vdenisenko\DbHelper\DbHelper\bin\Debug\Reports\16_Nov 06_30_46_DiscussionThreads_ORIGIN.txt D:\vdenisenko\DbHelper\DbHelper\bin\Debug\Reports\16_Nov 06_30_46_DiscussionThreads_ORIGIN.txt
System.Diagnostics.Process.Start(@"C:\Program Files (x86)\KDiff3\kdiff3.exe", diffCmd);
//specification is here http://kdiff3.sourceforge.net/doc/documentation.html
它运行kdiff3工具,但文件名或命令有问题...你能看一下截图并说出错了吗?
答案 0 :(得分:4)
您需要使用Process.Start()
:
string kdiffPath = @"c:\Program Files\Kdiff3.exe"; // here is full path to kdiff utility
string fileName = @"d:\file1.txt";
string fileName2 = @"d:\file2.txt";
Process.Start(kdiffPath,String.Format("\"{0}\" \"{1}\"",fileName,fileName2));
文档中描述的参数:kdiff3 file1 file2
答案 1 :(得分:2)
var args = String.Format("{0} {1}", fileName, fileName2);
Process.Start(kdiffPath, args);
答案 2 :(得分:0)
这将从您的控制台应用程序运行该程序
Process p = new Process();
p.StartInfo.FileName = kdiffPath;
p.StartInfo.Arguments = "\"" + fileName + "\" \"" + fileName2 + "\"";
p.Start();
除非您尝试做其他事情,否则您需要提供更多详细信息。
答案 3 :(得分:0)
string kdiffPath = @"c:\Program Files\Kdiff3.exe"; // here is full path to kdiff utility
string fileName = @"d:\file1.txt";
string fileName2 = @"d:\file2.txt";
ProcessStartInfo psi = new ProcessStartInfo(kdiffPath);
psi.RedirectStandardOutput = true;
psi.WindowStyle = ProcessWindowStyle.Hidden;
psi.UseShellExecute = false;
psi.Arguments = fileName + " " + fileName2;
Process app = Process.Start(psi);
StreamReader reader = app.StandardOutput;
//get reponse from console app in your app
do
{
string line = reader.ReadLine();
}
while(!reader.EndOfStream);
app.WaitForExit();