0

I'm writing a windows phone 8 application that have following functions

  1. Download a zip file from the internet
  2. Extract it to the isolated storage

I'm looking for a solution to deal with it but haven't found once. If you have any suggestion please help.

Thanks in advance!

EDIT:

I break it down into several steps:

  1. Check if storage is available - DONE

  2. Check if file is compressed - DONE

  3. Use Background Transfer (or another method) to download to local folder and display information to user (percentage, ect.) - NOT YET

  4. Unzip file to desired location in isolated storage - NOT YET

  5. Do stuffs after that... - DONE


For step 4, I found and modified some script to extract file to isolated storage (using SharpGIS.UnZipper lib):

public async void UnzipAndSaveFiles(Stream stream, string name)
{
    using (IsolatedStorageFile isoStore = IsolatedStorageFile.GetUserStoreForApplication())
    {
        using (var zipStream = new UnZipper(stream))
        {
            foreach (string file in zipStream.FileNamesInZip)
            {
                string fileName = Path.GetFileName(file);

                if (!string.IsNullOrEmpty(fileName))
                {
                    StorageFolder folder = ApplicationData.Current.LocalFolder;
                    folder = await folder.CreateFolderAsync("html", CreationCollisionOption.OpenIfExists);
                    StorageFile file1 = await folder.CreateFileAsync(name, CreationCollisionOption.ReplaceExisting);
                    //save file entry to storage
                    using (var writer = new StreamWriter(await file1.OpenStreamForWriteAsync()))
                    {
                        writer.Write(file);
                    }
                }
            }
        }
    }
}

This code is untested (since I haven't downloaded any file).

Can anyone point out any thing that should be corrected (enhanced)?

Can anyone help me to modify it to extract password-protected file (Obviously I have the key)?

haipham23
  • 456
  • 2
  • 8
  • 21
  • Might want to try DotNetZip. You can get using the NuGet manager. As for downloading a file off the internet there are a lot of answers on stackoverflow. – Chubosaurus Software Jul 28 '14 at 03:42
  • This link might help you. http://www.sharpgis.net/post/2009/04/22/REALLY-small-unzip-utility-for-Silverlight – Balasubramani M Jul 28 '14 at 04:37
  • Could follow these too: http://stackoverflow.com/questions/11742348/extract-zip-file-from-isolatedstorage http://stackoverflow.com/questions/22889276/how-to-unzip-a-file-in-isolatedstorage-in-windows-phone-8-app – Kulasangar Jul 28 '14 at 06:22

0 Answers0