I have problems in using SharpZipLib with isolated storage in WP7 to zip subfolders in isolated storage. My folder structure is like I’m having a rootFolder in isolated storage and inside that there is subFolder having some text files and more subfolders (contains .jpg and .png). I could go for Dotnetzip but I’m not sure it is available for WP7 or not and about its usage.
-
I am able to get all the file pathes in a list by recursively traversing on root folder. At present I am able to zip multiple files but only when they are inside a single folder.
-
Can’t find way to zip subFolder with correct hierarchy of folder and file structure and save it inside isolated storage. Also needs to unzip it with correct folder and file structure.
You can do this with SharpZipLib for Silverlight/Windows Phone 7.
The following code is based on this example and demonstrates how to zip a root folder including subfolders and files.
Short overview:
button1_Clickprepares some dummy folders and files for proof of concept: a folder root containing a file and two subfolders each also containing a file, then it callsCreateZipto compress the whole directory tree starting with rootCreateZipprepares the zip file and starts recursive folder compression by callingCompressFolderCompressFolderadds all files in a given dir to the zip file and recurses into subdirectoriesThe code: