Delta Compression in .NET

Someone was able to perform compression in the .NET environment to generate deltas between files. I would like to use this functionality, if at all possible, perhaps using the functionality in msdelta.dll. I am also interested in how to create a delta using other libraries (preferably open source).

+7
source share
2 answers

I hope this is not a shameless plugin, but I wrote a cover library for both PatchAPI and MSDelta for my own purposes.

The library is dual licensed under MS-PL and DBAD-PL and is available on GitHub .

I’m working on the idea of ​​publishing a project on NuGet, but for now, you can download the source code and create and apply the delta.

Creating a delta should be self-evident:

var compression = new MsDeltaCompression(); /* or PatchApiCompression(); */ compression.CreateDelta(sourcePath, destinationPath, deltaPath); 

And the delta is equally self-evident (I hope):

 var compression = new MsDeltaCompression(); /* or PatchApiCompression(); */ compression.ApplyDelta(deltaPath, sourcePath, destinationPath); 

Tested on x86, but P / Invoke signatures should be equally valid for x64 and ia64.

If you have not decided whether you use PatchAPI or MSDelta, my README.md project tries to suggest (briefly) which one you should use, but otherwise, the documentation for Microsoft Delta Compression says MSDelta vs. PatchAPI:

MSDelta ... can create much smaller compressed files than those produced by other methods . Windows Vista Delivery is the next generation of technology previously released as PatchAPI (which will continue to be supported).

Emphasis on mine.

+6
source

Fossil SCM has a delta compression algorithm implemented in C, and I made its port in C # here: https://github.com/endel/FossilDelta

To create a delta, you must specify the source and target byte[] . It returns as byte[] , which you can apply later.

 byte[] origin = System.IO.File.ReadAllBytes ("old-file"); byte[] target = System.IO.File.ReadAllBytes ("new-file"); byte[] delta = Fossil.Delta.Create(origin, target); 

Having a delta, you can apply the changes in the source file as follows:

 byte[] applied = Fossil.Delta.Apply(origin, delta); 

I think it's worth mentioning that the author of this algorithm is the same SQLite author, so he has some trust.

+1
source

All Articles