Microsoft Study Bible

October 14, 2009

Best way to decompress .zip file in C#?

Filed under: Developer tools and applications — Tags: , , — Jackson @ 4:37 am

To decompress .zip file, there are many ways on the internet such as  using System.IO.Compression.GZipStream ,and J # library function ,etc. Finally ,many ways were tried out ,and it is best to use System.Shell.Folder.copyHere(oItem [, intOptions]) .
So, let’s look up the detailed information about this function.
1. firstly ,we should add the reference to  “Shell32.dll” in windows\system32.
2. add the method .
static void UnZip(string zipFile,string destFolder)
            {
                        Shell32.ShellClass sc = new Shell32.ShellClass();
                        Shell32.Folder SrcFolder = sc.NameSpace(zipFile);
                        Shell32.Folder DestFolder = sc.NameSpace(destFolder);
                        Shell32.FolderItems items = SrcFolder.Items();
                        DestFolder.CopyHere(items, 20);
            }
Notice :destFolder must be the folder existed as this method could not automatically create folder .

Powered by WordPress

Close
E-mail It