How can I unzip a zip file on the server programatically?

I have a zip file that I am uploading to server.
It contains a host of Windows Media Audio Files.

I need to unzip this file programatically.
Is this possible?
If so, can you provide a soution.

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

this requires a program/service that is looking at a dir (filesystemwatcher) and if a new .zip file has been uploaded unzip it.

filesystem stuff

zip stuff


plz provide more infromation, eg, where are the files being unziped to?,... what is going to happenb with the original zip file etc.
Upload the file and then use SharpZipLib to unzip.  I use this library everytime I need file zipping.  You can find it at  If you need any extra help with this just ask.
smaccaAuthor Commented:
I have downloaded SharpZipLib but cannot determine how to unzip from the API docs.
Can you provide any code examples of the unzip process?
// this code block needs 2 variables: destination (path to the destination zip file) and file (path to the source file)
// you could add more ZipEntrys to zip multiple files or directories

using ICSharpCode.SharpZipLib.Zip;


ZipOutputStream zipOut = new ZipOutputStream(File.Create(destination));

ICSharpCode.SharpZipLib.Checksums.Crc32 crc = new ICSharpCode.SharpZipLib.Checksums.Crc32();

System.IO.FileStream fs = System.IO.File.OpenRead(file);                  
byte[] buffer = new byte[fs.Length];
fs.Read(buffer, 0, buffer.Length);
ZipEntry entry = new ZipEntry(file.Substring(startingPath.Length-1)); // makes file path relative

//this block forces compressed file type to be stored
// not much sense in trying to compress further
// more types should be added and more elegantly
bool compressedFileType = false;
string fileType = file.ToUpper();
if (fileType.EndsWith(".ZIP") || fileType.EndsWith(".RAR") ||fileType.EndsWith(".GZ")  || fileType.EndsWith(".LZH") ||
     fileType.EndsWith(".PAK") || fileType.EndsWith(".CAB"))
     compressedFileType = true;

if (!compressedFileType)
    entry.CompressionMethod = CompressionMethod.Deflated; //deflate
    entry.CompressionMethod = CompressionMethod.Stored; //store

entry.DateTime = DateTime.Now;

// set Size and the crc, because the information
// about the size and crc should be stored in the header
// if it is not set it is automatically written in the footer.
// (in this case size == crc == -1 in the header)
// Some ZIP programs have problems with zip files that don't store
// the size and crc in the header.
entry.Size = fs.Length;                        
entry.Crc  = crc.Value;                  
s.Write(buffer, 0, buffer.Length);


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.