Reputation: 107
So I am a newbie and I couldn't find a proper answer to this on the internet. After digging a little bit here is what I came up with.
Upvotes: -1
Views: 2285
Reputation: 11
Alternatively, add the Nuget Package DiffMatchPatch and add it to your project.
A Demo Code is as follows :
using System;
using System.IO;
using DiffMatchPatch;
namespace ConsoleApp_DMPTrial
{
class Program
{
static void Main(string[] args)
{
var dmp = DiffMatchPatchModule.Default;
string file1Content = "";
string file2Content = "";
using (StreamReader sr = new StreamReader("file1.json"))
{
file1Content = sr.ReadToEnd();
}
using (StreamReader sr = new StreamReader("file2.json"))
{
file2Content = sr.ReadToEnd();
}
var diffs = dmp.DiffMain(file1Content, file2Content);
dmp.DiffCleanupSemantic(diffs);
for (int i = 0; i < diffs.Count; i++)
{
Console.WriteLine(diffs[i]);
}
Console.ReadLine();
}
}
}
Upvotes: 1
Reputation: 107
Download google-diff-match-patch from here
One you have extracted it, open up your microsoft visual studio project
Go to View->Solution Explorer or press Ctrl+Alt+L
In solution Explorer right click on your project name and go to Add->Existing Item... or press Shift+Alt+A
In the dialog box that appears locate your diff-match-patch folder and go in csharp directory and select DiffMatchPatch.cs and click on Add
Then in solution explorer right click on References->Add Reference...
Search for System.Web and add it.
Now come back to your program (in my case Form1.cs) and type
using DiffMatchPatch;
Now you are ready to use all the functions of the diff-match-patch library in your C# program
Upvotes: 2