Question : C#.NET - decrompress a zip file

I've got an application that pulls down a zipped file via ftp and now needs to decrompress that file so that it can read the contents.  I've been looking around online, but all of the answeres I'm finding seem very hard to follow.  For example: http://www.codeproject.com/KB/cs/decompresswinshellapics.aspx
I find that code too hard to follow.  I'm not sure what it's doing and I'm not sure how to tailor it to my needs.

Answer : C#.NET - decrompress a zip file

to unzip a package, you should do something like:

using (Package package = Package.Open("yourzip.zip", FileMode.Open, FileAccess.Read))
{
    foreach (PackagePart part in package.GetParts())
    {
        Stream input = part.GetStream();
        FileStream output = new FileStream(part.Uri, FileMode.Create, FileAccess.Write);
        CopyStream(input, output);
        input.Close();
        output.Close();      
    }
}

// you will need this helper method:
private static void CopyStream(Stream source, Stream target)
{
    const int bufSize = 0x1000;
    byte[] buf = new byte[bufSize];
    int bytesRead = 0;
    while ((bytesRead = source.Read(buf, 0, bufSize)) > 0)
        target.Write(buf, 0, bytesRead);
}// end:CopyStream()

Random Solutions  
 
programming4us programming4us