Quantcast
Channel: Recent Threads — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 204402

Open a downloaded Zip

$
0
0

Hi,
I've made an app that download some zip-files and then list them so I could chose wich to open. The downloading and listning works fine but when I try to unzip a file I get the output "Failed to locate the zip header" in my catch. Does someone know what might cause this?

I'm using System.IO.Compression for the zip-part and had to manually install the System.IO.Compression.Filesystem to be able to use "ZipFile".
For file handling I use "PCLStorage"

async void Clicked_Open(object sender, System.EventArgs e)
        {
            IFile clickedFile = myList.SelectedItem as IFile;
            await DisplayAlert("Alert", clickedFile.Path, "OK");
            UnzipFiles(clickedFile, rootFolder.Path);
        }

        private async void UnzipFiles(IFile theZip, string theFolder)
        {
            try
            {
                ZipFile.ExtractToDirectory(theZip.Path, theFolder);
            }
            catch (Exception e)
            {
                await DisplayAlert("Alert", "error:" + e.Message, "OK");
            }
        }

Viewing all articles
Browse latest Browse all 204402

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>