ryanzec
ryanzec

Reputation: 28040

Working With Compressed Files In C#

I am looking for a c# library that is open source but licensed to allow development in closed sourced projects (so something like MIT/BSD style) that allows me to work with compressed files. I am really not that picky about what compression is used, only that it is something common (.zip, .rar, .tar, .tar.gz, etc...).

The reason I need this functionality is that I am building a web application platform and right now the best and easiest way to be able to build and distribute modules (or plug-ins) for the platform I think is with a compressed file. The compressed file would hold the .dll files which would include source code and razor views and also any number of supporting files (images, dotlesscss, javascript, etc...). What I want to be able to do is through the web application platform itself, allow an user to be able to just upload one compressed file and have the web application copy the file, extract all the files in it, and the copy the extracted files into the correct locations.

Upvotes: 0

Views: 277

Answers (5)

Alexei Levenkov
Alexei Levenkov

Reputation: 100547

If you want to package multiple files into one compressed file consider using classes from System.IO.Packaging - http://msdn.microsoft.com/en-us/library/ms569886.aspx - allows to put files into Zip file (requires one additional XML file on topof your content).

Upvotes: 0

Cheeso
Cheeso

Reputation: 192467

If you want ZIP capability, that's not really present in the .Net Framework and you'll need to go to a 3rd party library like SharpZipLib or DotNetZip. SharpZipLib is not BSD, it is GPL or LGPL, and may not be suitable for you based on your description. DotNetZip is Ms-PL, which is BSD-like, check http://www.opensource.org/licenses/ms-pl .

a GZIP stream is available in the System.IO.Compression namespace, which IS builtin to the .NET Framework base class library, but that stream does not read or unpack tar.gz files, which I guess is what you'd want to use if you were bundling multiple files together. GZIP by itself defaults to storing just ONE file in a compressed archive, and you can use that GZipStream to do that, but it won't do Tars. SharpZipLib does Tars, but...the license.

There are Ms-PL 3rd party (small) tar libraries that, combined with GZIP in .NET, can let you read tar.gz (or .tgz) files easily.
http://cheeso.members.winisp.net/srcview.aspx?dir=Tar

Upvotes: 0

keyboardP
keyboardP

Reputation: 69372

DotNetZip is quite a popular open-source library. It uses the Microsoft Public License (Ms-PL) license, which you can read about here and see if it suits your needs.

Upvotes: 2

Alan Barber
Alan Barber

Reputation: 983

.net already has built in support for gzip and deflate in system.io.compression

Upvotes: 0

Joel Martinez
Joel Martinez

Reputation: 47749

This is already built into the .net framework :-) just check out the compression namespace:
http://msdn.microsoft.com/en-us/library/system.io.compression.aspx

Upvotes: 6

Related Questions