Jean Paul's Blog

There are 2 types of People in the World, One who Likes SharePoint and..

    Advertisements
  • Microsoft MVP

  • MindCracker MVP

  • CodeProject MVP

  • eBook on SharePoint 2010

  • eBook on Design Patterns

  • eBook on Windows Azure

  • NLayers Framework @ CodePlex

  • MSDN Forums

  • .Net vs. Java

    Due to Public Demand
  • Advertisements

Simplest way of zipping and unzipping in .Net

Posted by Paul on February 4, 2011


Add reference to Shell32.dll in c:\windows\system32 folder

Use the following unzipping code:

DirectoryInfo di = new DirectoryInfo(@”C:\Temp\”);
            foreach (FileInfo fi in di.GetFiles(“*.zip”))
            {
                String file = fi.ToString();
                var destinationPath = @”C:\Temp\AppName\”;
                if (!Directory.Exists(destinationPath))
                    Directory.CreateDirectory(destinationPath);
                Shell sh = new Shell();
                Folder destFlder = sh.NameSpace(destinationPath);
                Folder srcFlder = sh.NameSpace(fi.FullName);
                foreach (FolderItem F in srcFlder.Items())
                {
                    destFlder.CopyHere(F, null);
                }
            }

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s