Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Compress a file with RAR

I have a text file that I want to compress after it gets an specified size. I've already seen GZipStream which works great, but RAR compression is much better.

I've been looking for a library that can compress a file with RAR (I really don't care about extracting or uncompressing), but I couldn't find one yet.

like image 226
gabriel290687 Avatar asked Nov 10 '11 18:11

gabriel290687


People also ask

Which compresses better RAR or ZIP?

The RAR file format makes use of a compression algorithm. It is comparatively much more efficient and substantially better than the DEFLATE method of compression in ZIP.


1 Answers

As the RAR compression algorithm isn't free (only the decompression algorithm is), you won't find a library for it (or have to purchase a license).

A good alternative is the LZMA SDK that delivers the compression algorithms used in 7-Zip.

For a compression ratio/speed comparison, you can have a look e.g. at the Maximum Compression summary page, ranks 50 and 52, comparing WinRAR 4.01 in "Best Solid" mode and 7-Zip 9.22 in "Ultra" mode. WinRAR compresses only slightly better (<1%) and faster, 7-Zip decompresses faster.

Note that, as peachykeen noted, if you look at the efficiency ratings instead of size, WinRAR in normal mode is much faster than 7-Zip.

like image 141
schnaader Avatar answered Oct 06 '22 23:10

schnaader