Free compression library for C# which supports 7zip (LZMA) [closed]
Asked Answered
D

5

20

I have a program (written in C#) that reads/writes its data directly (direct file access without server) to firebird database files. For a better exchange I want to (un)compress them on import/export for a better exchange over the internet without the need of an external program to (un)compress them.

I know #ziplib which supports Zip, GZip, Tar and BZip2.

What else free compression libraries for C# do you know? Is there a .NET library which supports LZMA so i can read/write ".7z" files?

Dispute answered 16/1, 2009 at 10:21 Comment(0)
S
22

There is a good article written by Peter Bromberg:

7Zip (LZMA) In-Memory Compression with C#

Shows a simple C# SevenZip.Compression.Lzma.SevenZipHelper class to enable high-compression of in-memory objects with C#. Adds a new 7Zip format LZMA Cookie Compression class to the previously published CookieCompression utility.

Secco answered 16/1, 2009 at 10:27 Comment(3)
@Kissaki external links are okay for certain situations; including: 1)The amount of relevant external material is huge, for example a specification. 2) Links which are supporting information only 3) material which can't be copy-pasted due to copyrightsVitalism
I'm not sure why that specific web.archive.org URL was used in this answer but the source URL is nullskull.com/a/768/7zip-lzma-inmemory-compression-with-c.aspx. Also, some helpful information with examples can be found at https://mcmap.net/q/442963/-how-to-use-the-7z-sdk-to-compress-and-decompress-a-file.Mudd
Keep in mind, Peter Bromberg's SevenZipHelper default class is extremely slow with the default properties. 3600 (6c/12t) vs 144Mb sql file: default settings: 135 sec! -> 7.9Mb vs without properties (//encoder.SetCoderProperties): 34 sec -> 8.2Mb vs using 7zr.exe: 9 sec!!! 8.2Mb Imo the programatical settings are not using all threads, only two of them, vs 7zr.exe which used at least 6 threads.Vermicide
C
26

7-zip has a free source code, public domain C# SDK for the LZMA algorithm:

http://www.7-zip.org/sdk.html

Cobaltite answered 16/1, 2009 at 10:26 Comment(3)
It might be worth pointing out that it's free source code, public domain, and in C# :)Gurge
@Jon Skeet: You ar right. Added this information.Cobaltite
Some other helpful examples on how to use it can be found at https://mcmap.net/q/442963/-how-to-use-the-7z-sdk-to-compress-and-decompress-a-file.Mudd
S
22

There is a good article written by Peter Bromberg:

7Zip (LZMA) In-Memory Compression with C#

Shows a simple C# SevenZip.Compression.Lzma.SevenZipHelper class to enable high-compression of in-memory objects with C#. Adds a new 7Zip format LZMA Cookie Compression class to the previously published CookieCompression utility.

Secco answered 16/1, 2009 at 10:27 Comment(3)
@Kissaki external links are okay for certain situations; including: 1)The amount of relevant external material is huge, for example a specification. 2) Links which are supporting information only 3) material which can't be copy-pasted due to copyrightsVitalism
I'm not sure why that specific web.archive.org URL was used in this answer but the source URL is nullskull.com/a/768/7zip-lzma-inmemory-compression-with-c.aspx. Also, some helpful information with examples can be found at https://mcmap.net/q/442963/-how-to-use-the-7z-sdk-to-compress-and-decompress-a-file.Mudd
Keep in mind, Peter Bromberg's SevenZipHelper default class is extremely slow with the default properties. 3600 (6c/12t) vs 144Mb sql file: default settings: 135 sec! -> 7.9Mb vs without properties (//encoder.SetCoderProperties): 34 sec -> 8.2Mb vs using 7zr.exe: 9 sec!!! 8.2Mb Imo the programatical settings are not using all threads, only two of them, vs 7zr.exe which used at least 6 threads.Vermicide
N
7

You may try SevenZipSharp

Noheminoil answered 23/2, 2009 at 0:8 Comment(1)
It's under LGPL v3.0 if anyone need the license.Cowgill
M
4

It seems to be quite a little known fact but .NET library includes packaging/compression API

Merkel answered 16/1, 2009 at 10:29 Comment(6)
Here is an example using that API: syntaxwarriors.com/2012/…Wende
Is this MS specific? Nowaways I would not like to use a MS-only solution anymore. I mean if I pack a file, I would expect it to be used on non-MS-machines as well.Verbena
@Wende that link is now dead.Mudd
@ArvoBowen Look here: #941082Wende
@Wende great question to look at but I don't think that has anything to do with 7zip (and that's why I came to see this question. I ended up getting the 7zip SDK from 7-zip.org/sdk.html and read up on the article found at nullskull.com/a/768/7zip-lzma-inmemory-compression-with-c.aspx. I was able to use that guys SevenZipHelper.cs file with the SDK from 7-zip.org and got it to work.Mudd
It has to do with the suggested answer. How to do it natively in C#. With no libraries, which is exactly what the dead link showed once upon a time.Wende
U
1

If you are writing individual files, then you could just treat it as a stream and use the inbuilt GZipStream / DeflateStream (although in some tests I did, #ZipLib out-performed the MS offering for both ratio and speed). Or there is inbuilt zip support somewhere in the framework. I don't know about LZMA, though.

Unsound answered 16/1, 2009 at 10:29 Comment(2)
Beware: GZipStream has a size limitation of 4GbHasan
please refere to https://mcmap.net/q/276613/-deflatestream-4gb-limit-in-netSwain

© 2022 - 2024 — McMap. All rights reserved.