1. DiffPlex - a .NET Diff Generator http://diffplex.codeplex.com/SourceControl/changeset/view/052fd342999b 原网站dll下载
http://diffplex.codeplex.com/
简介:
具体使用可以参考http://diffplex.codeplex.com/wikipage?title=library&referringTitle=Home
IDiffer是差异比较的核心类,提供了两个文本的低精度的大致比较
ISidebySideDiff:提供了高精度的比较以及可以用两栏对比显示差异
接口
Silverlight
Website
2.diffengine
简介:
功能强大,
缺点:文本每行不能超过1024个字符
DifferenceEngine.DiffList_TextFile sourceFile null;
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;
}
}
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;
}
}
获取新增内容示例:
string str = ((DifferenceEngine.TextLine)(destinationFile.GetByIndex(span.DestIndex))).Line;
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