Extract ZIp File Using Library JSZip


  • I am working in windows 8 using HTML/JS. I am trying to Extract a Zip file which is picked file using FilePicker.

    To extract Zip file I am using this forum.

    In this Link there is a function to Extract Zip file unzipAsync 


    function unzipAsync(filePath, replaceIfExists) {
        var fileCollisionOption = replaceIfExists ?
            storage.CreationCollisionOption.replaceExisting :
        return storage.StorageFile
            .then(function (zipFileContents) {
                //Create the zip data in memory
                var zip = new JSZip(zipFileContents);
                //Extract files
                var promises = [];
                var lf = storage.ApplicationData.current.localFolder;
                _.each(zip.files, function (zippedFile) {
                    //Create new file
                        .createFileAsync(zippedFile.name, fileCollisionOption)
                        .then(function (localStorageFile) {
                            //Copy the zipped file's contents into the local storage file
                            var fileContents = zip.file(zippedFile.name).asUint8Array();
                            return storage.FileIO
                                .writeBytesAsync(localStorageFile, fileContents);
                return WinJS.Promise.join(promises);


    Before this I added JSZIP Library to Project folder. But when run this function I am getting the error.

    Help me, How Can I integrate the Library to my project. Here is my sample Project


    function getFileAsUint8Array(file) {
        return storage.FileIO.readBufferAsync(file)
            .then(function (buffer) {
                //Read the file into a byte array
                var fileContents = new Uint8Array(buffer.length);
                var dataReader = storage.Streams.DataReader.fromBuffer(buffer);
                return fileContents;

    Now it is working with out error. But it is not doing any thing like extracting my file.


    - If anyone knows any another way which better than this or other Library which I can use to extract file for WinJS; please suggest me. 


    • Edited by GDEVENDRAK Tuesday, December 17, 2013 6:13 AM
    Thursday, December 12, 2013 2:29 PM


All replies

  • you can try the built in WinJS library, check this


    • Proposed as answer by Ahmed-Fouad Friday, December 13, 2013 1:40 AM
    • Marked as answer by GDEVENDRAK Friday, December 20, 2013 1:00 PM
    Friday, December 13, 2013 1:39 AM
  •  @Ahmed-Fouad

     Your Sample is not working properly. I am getting exception after Extraction. 

     MSG1.Text = string.Format("Your File is decompressed at {0}"+folder.Path); 

     Where you are showing result message.

    Here are the ScreenShots.  Here I tried to extract your Sample Zip file & you can see all folder contains in the ZIp file are extracted in main folder means it is not properly extracted.

    Here is the Class1.cs file.
    Now it is working as exact extracted Zip file.

    Please try to change your code in sample if it is worth-full,
    Thank You for great sample.


    • Edited by GDEVENDRAK Friday, December 20, 2013 12:59 PM
    Friday, December 13, 2013 5:29 AM