Friday, March 19, 2004

System.IO.Compression

I'm lucky enough to be getting paid to write stuff against Whidbey right now. Although the tooling leaves something to be desired, the APIs are pretty solid, and it's been interesting using the new stuff. Today, I came across a namespace that I think falls squarely into the “I could never give up the CLR libraries, and now they're just getting better” camp:


System.IO.Compression


It has classes like GZipStream in it. The wrap a regular stream, and compress or decompress whatever you pass through it. Nice, eh?

6 comments:

  1. Sweet. I complained about the absence of ZIP support in the framework a while back.
    http://weblogs.asp.net/kdente/archive/2003/05/27/7649.aspx
    Nice to see that it's being addressed in Whidbey.

    ReplyDelete
  2. I've been playing around with the classes in the System.IO.Compression namespace. How the heck do you unzip .zip files using the GZipStream?

    ReplyDelete
  3. System.IO.Compression.GZipStream
    System.IO.Compression.DeflateStream

    > How the heck do you unzip .zip files using the GZipStream?

    For what there is so far in the framework, I don't think that's possible with any simple commands, except calling java equivalent perhaps.

    Currently the options seem to be

    a) use #ziplib if you do not require support for old pkzip archives (ones packed in DOS often years ago), this could probably be modified to use the Whidbey system.io.compression namespace, for what benefit - I am not sure.

    b) interop with the InfoZip's implementation of ziplib (good support for older stuff)

    c) few companies offer managed zip libs for a fee, these can be worse for old stuff than InfoZip - from what I've tested.

    d) organicbit ziplib wrapper - also few problems with older zip archives, ziplib does not support those entirely

    ReplyDelete
  4. How to Use this in VBdot Frame Work 1.1

    ReplyDelete
  5. Hi,

    Was wondered if this can be used for http compression. My website, www.uniforms-4u.com has pretty big css and Js files, I heard that http compression will help reduce the size of the page.

    Any idea?

    Thanks!

    ReplyDelete
  6. Well, I suppose you could do it by coding, but I think it would in general be better to leave compression to the webserver. So I would stay away from System.IO.Compression for now and look for the configuration switch or whatever that enables this (it would depend on which webserver you're using if nothing else). No idea where that might be, but I'm sure if you took the time to do some research on Google you'd find something pretty quickly.

    ReplyDelete