c#做對比軟件
一些 HTML內容比較/文本差異比較 開源代碼
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
Website2.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;
}
}
獲取新增內容示例:
string str = ((DifferenceEngine.TextLine)(destinationFile.GetByIndex(span.DestIndex))).Line;
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
c#做對比軟件