Create tar.gz using .NET - c#

I am new to .NET. Is it possible to create a tar.gz using a .NET environment? If yes, how?

I guess you can also use
http://sevenziplib.codeplex.com/

Have a look at SharpZipLib
http://www.icsharpcode.net/OpenSource/SharpZipLib/Download.aspx

Yes, it is possible.
Create a tar archive using a suitable library, say http://code.google.com/p/tar-cs/.
Then compress the tar using GZipStream class.
Of course, you should be familiar with streams.

Related

What is an alternate of ionic zip in C#?

I use Ionic.Zip to zip and unzip my data. But I find that Ionic.Zip is not capable of handling large file sizes (> 3GB).
So is there any third party tool that we can use to replace Ionic.Zip?
If you can use .NET Framework 4.5+, ZipArchive is now part of the BCL, as described by the "What's New in the .NET 4.5 Base Class Library" article.
Also, IMHO the 'de facto' third-party library for this is SharpZipLib from the SharpDevelop team.
It can actually handle larger files.
For that you need to use property:
UseZip64WhenSaving = Zip64Option.Always
Xceed realtimes zip for .NET
Quote from their website:
The size or number of files in a Zip archive has absolutely no impact on memory and disk-space requirements.
Might be cheaper options out there.
System.IO.Compression Namespace has DeflateStream and GZipStream classes.

Extract .tbz file using .net

I'm trying to extract a .tbz file using .net
Anyone have any suggestions?
The file will be very large (3GB) if this makes any difference.
First you'll need to know about, how to implement, or use a supporting library for BZIP2 decompression. Then you will need to do the same, in a different fashion, and de-archive the contents of the resulting TAR file.
You can use SharpZipLib:
http://www.icsharpcode.net/opensource/sharpziplib/
However, it is licensed under the GPL, with an exception that I'm not familiar with, so you'll have to read carefully to see if it suits your needs.

java.util.zip.deflater equivalent in c#

does anyone know how can I achieve java's Deflater.deflate() functionality in .NET so it would be understandable for java's Infalter.inflate() method?
regards,
Rafal
I have used #zipLib. It is pretty straight forward.
Taken from their site:
#ziplib (SharpZipLib, formerly NZipLib) is a Zip, GZip, Tar and BZip2 library written entirely in C# for the .NET platform. It is implemented as an assembly (installable in the GAC), and thus can easily be incorporated into other projects (in any .NET language). The creator of #ziplib put it this way: "I've ported the zip library over to C# because I needed gzip/zip compression and I didn't want to use libzip.dll or something like this. I want all in pure C#."
ZlibStream class inside DotNetZip package (https://dotnetzip.codeplex.com/) is equivalent to java.util.zip.deflater.
Nuget: Install-Package DotNetZip
usage for byte array:
ZlibStream.CompressBuffer(dataBytesArray);
ZlibStream.UncompressBuffer(dataBytesArray);
it also has String compression and decompression, and the class can be used with streams exactly the same way as .NET DefalteStream. Please note that DeflateStream of DotNetZip is not the same as its Java, ZlibStream is.
Additional Info:
DeflateStream of .NET is not compatible with Deflate in Java. In fact, Java uses Zlib and adds 2-6 bytes header and 4 bytes checksum by default. Cutting off the bytes (suggested by some articles like http://blogs.msdn.com/b/bclteam/archive/2007/05/16/system-io-compression-capabilities-kim-hamilton.aspx) will work, but I don't suggest it as parsing header length may cause bugs.
I don't suggest SharpZipLib as it is pure C# and usually performance is important working with compression and decompression data. Look at http://www.codeproject.com/Articles/434583/SharpZipLib-or-DotNetZip-Which-should-you-use
Check System.IO.Compression namespace. It has DeflateStream. DeflateStream uses Deflate algorithm for compression, and so does java.util.zip.deflater. So you can compress with .NET and decompress with Java implementation and vice versa.
There's
ZipPackage Class
or
GZipStream Class
which might help, but I don't know how easy they are to use or if compatible with java (sorry not a great answer).
There's a nice blog post about zip stuff in: http://blogs.msdn.com/b/bclteam/archive/2010/06/28/working-with-zip-files-in-net.aspx
Or a few open source zip utilities around for c#.

Compression Assemblies for C#/.Net?

I know about SharpZipLib...but what else is out there? I'd like to make myself a file archiving utility that supports multiple compression formats. Any ideas?
QuickLZ claims to be the fastest in the world.
http://www.quicklz.com/
How about System.IO.Packaging?
http://msdn.microsoft.com/en-us/library/system.io.packaging.aspx
There's the built-in System.IO.Compression library which supports GZip and Deflate. That's not a bad place to start as its documentation is better than most.
LZMA SDK (7-Zip format) - one of the more efficient algorithms out there.
http://www.7-zip.org/sdk.html
http://dotnetzip.codeplex.com/ <-- imho easier than sharpziplib
http://sevenzipsharp.codeplex.com/ <-- wrapper around 7zip
http://www.chilkatsoft.com/zip-dotnet.asp <-- not free. bz2, gzip and .z

Are there any compression and encryption libraries in C#?

I want to compress some files (into the ZIP format) and encrypt them if possible using C#. Is there some way to do this?
Can encryption be done as a part of the compression itself?
For compression, look at the System.IO.Compression namespace and for encryption look at System.Security.Cryptography.
For Zip Compression, have you seen http://www.icsharpcode.net/OpenSource/SharpZipLib/
I know the question is already old, but I must add my two cents.
First, some definitions:
Zip: Archive format for regrouping files and folders into a single file, and optionally encrypting data.
Deflate: One of the compression algorithms used within a Zip file to compress the data. The most popular one.
GZip: A single file compressed with deflate, with a small header and footer.
Now, System.IO.Compression does not do Zip archiving. It does deflate and gzip compression, thus will compress a single blob of data into another single blob of data.
So, if you're looking for an archive format that can group many files and folders, you need Zip libraries like:
Xceed Zip (it does support strong encryption)
SharpZipLib
If you only need to compress and encrypt a single blob of data, then look under System.IO.Compression and System.Security.Cryptography.
The GZipStream class is a native way to handle compression.
As for encryption, there are many ways to do it, most of them in the System.Security namespace. They can be done chained (encrypt a compressed stream or compress an encrypted stream).
Chilkat provides .NET libraries for compression and encryption.
I'm not sure if the steps can be combined, but .NET has good support for basic crypto. Here's an article on it.
If they cannot be combined, do compression first and then encryption. Compressing an already encrypted file will lead to poor compression ratios, because a lot of redundancy is removed.
Here is a useful topic:
Help in creating Zip files from .Net and reading them from Java
System.IO.Packaging namespace gives you useful classes to compress data in zip format and support rights management.
There isn't anything you can use directly in C#, however you can use some libraries from J# to do it for you:
http://msdn.microsoft.com/en-us/magazine/cc164129.aspx
Should do just what you want?
With regards to the encryption, have a look at these links:
http://www.codeproject.com/KB/security/fileencryptdecrypt.aspx
http://www.obviex.com/samples/EncryptionWithSalt.aspx

Categories