Simplest way of zipping and unzipping in .Net

Add reference to Shell32.dll in c:windowssystem32 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:TempAppName”;
                if (!Directory.Exists(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);

Leave a Reply

Your email address will not be published. Required fields are marked *