views:

199

answers:

5

Im in a fix. need to download a zip file from network location and then decompress it on local machine and use the files. The only constraint is i cannot use any third party dll.

Please reply fast. its very urgent.

A: 

A quick google search turned this up. GZipStream Class MSDN Reference

antonlavey
"...however, this class does not inherently provide functionality for adding files to or extracting files from .zip archives..."
danbystrom
+3  A: 

There is no "good" way to do this. You could obviously implement the ZIP algorithm yourself using publicly available information on the ZIP file structure and classes such as DeflateStream (though even this may not work if it is not compressed using the DEFLATE algorithm). There is some information on possible alternatives in this blog post, but the short version is that you will either have to use a third-party library or re-write one yourself.

If this is a situation where you would be able to release the source code in a GPL'd manner, you could copy-paste the code from a project like SharpZipLib into your own, thereby sidestepping the requirement to use the DLL. Other than that, though, why can't you use third-party DLLs?

Ryan Mentley
A: 

GZipStream is most commonly used for WCF data compression. Dont use that here.

You can try this ZIP library to compress into files:

http://www.icsharpcode.net/opensource/sharpziplib/

Turek
This does not appear to be a WCF question, and GZipStream isn't going to help with ZIP files, which usually use the DEFLATE algorithm.
Ryan Mentley
You didn't understand my post. I suggested other approach...
Turek
+2  A: 

I'm not sure if it's still available in VS2010, but in earlier versions J# was included in VS and J# includes the java.util.zip class in the vjslib.dll, and since it's part of VS, it's not a third party DLL so you might be able to do it that way.

Here's a CodeProject article showing how to do this: Zip and Unzip from a C# program using J# runtime

ho1
Interesting, I didn't know it was there...
Thomas Levesque
+1  A: 

The .NET framework itself does not (currently) have official support for ZIP files. There are a couple of high-quality third-party free libraries available, and the J# runtime supports it, as others have noted.

I recommend the third-party solution, but if you absolutely can't do that, then there is one other trick: ZipPackage, which is part of WPF. It sort-of supports ZIP files (augmented with extra metadata), and works well enough for reading most ZIP files.

Stephen Cleary