Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 77050

Zip Extraction code not working for Android in xamarin forms

$
0
0

I am using below code for extraction in xamarin forms

  using (ZipArchive archive = ZipFile.OpenRead("Zip file path"))
                {
                    foreach (ZipArchiveEntry entry in archive.Entries)
                    {

                        var pathToInstall = Path.GetDirectoryName(Path.Combine("Extract Directory", entry.FullName));
                        if (!Directory.Exists(pathToInstall))
                        {
                        Directory.CreateDirectory(pathToInstall);
                        }
                        using (var entryStream = entry.Open())
                        {
                            entry.ExtractToFile(Path.Combine("Extract Directory", entry.FullName), true);

                        }

                    }

                }

Here** entry.ExtractToFile(Path.Combine("Extract Directory", entry.FullName), true)** is throwing below exception:

{System.IO.IOException: Invalid parameter
  at System.IO.File.SetLastWriteTime (System.String path, System.DateTime lastWriteTime) [0x0002a] in <d4a23bbd2f544c30a48c44dd622ce09f>:0 
  at System.IO.Compression.ZipFileExtensions.ExtractToFile (System.IO.Compression.ZipArchiveEntry source, System.String destinationFileName, System.Boolean overwrite) [0x00067] in <1a0f8b38772b44ca85cc92de9ff0e2e6>:0 
  at SharedProject.Infrastructures.Protocols.Smb.PackageManager.Extract (System.String zipPackagePath) [0x00059] in D:\VS2017\DocSyncMobile\Xamarin Forms\DocSync\DocSync\DocSync\Infrastructures\Protocols\Smb\PackageManager.cs:41 

However this code is working fine in windows.


Viewing all articles
Browse latest Browse all 77050

Trending Articles



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