c#做对比软件
2021-07-03 10:11
2.diffengine
简介:
功能强大,
缺点:文本每行不能超过1024个字符
DifferenceEngine.DiffList_TextFile destinationFile = null;
sourceFile = new DifferenceEngine.DiffList_TextFile("1.txt");
destinationFile = new DifferenceEngine.DiffList_TextFile("2.txt");
DifferenceEngine.DiffEngine engine = new DifferenceEngine.DiffEngine();
engine.ProcessDiff(sourceFile,destinationFile, DifferenceEngine.DiffEngineLevel.FastImperfect);
ArrayList diffLines = engine.DiffReport();
foreach (DifferenceEngine.DiffResultSpan span in diffLines)
{
switch (span.Status)
{
case ifferenceEngine.DiffResultSpanStatus.NoChange:
//没改变
break;
case DifferenceEngine.DiffResultSpanStatus.AddDestination:
//新增的
break;
case DifferenceEngine.DiffResultSpanStatus.DeleteSource:
//已删除的
break;
case DifferenceEngine.DiffResultSpanStatus.Replace:
//修改的
break;
default:
// 默认
break;
}
}
获取新增内容示例:
http://www.codeproject.com/KB/recipes/diffengine.aspx
3. htmldiff
简介:
HtmlDiff原本是Ruby版的HTML差异比较算法,后来有朋友做了个C#版本,特点是非常好用,过于简单
C#版: http://htmldiff.codeplex.com/
Ruby版: http://github.com/myobie/htmldiff
http://www.rohland.co.za/index.php/2009/10/31/csharp-html-diff-algorithm/
4.NDiffDiff: A Diff Implementation for Lines and Chars in Text File
简介:
提供Winform Demo
http://www.codeproject.com/KB/recipes/NBDiffDiff.aspx