Reputation: 105
I'm trying to implement zip functionality in my Xamarin Android mvvmCross Project.
I was wondering if there is an archiving library similar to Microsoft.Bcl.Compression for extracting files from a zip file and is supported by Mono Android. I have tried to use zlib portable but I noticed that it provides only compressing and uncompresing of streams.
Thank you in advance.
Upvotes: 3
Views: 2155
Reputation: 3249
PCLs don't provide access to the file system using paths. However, the Microsoft.Bcl.Compression
NUGet package adds stream based support for compression, including ZIP archives. Although this NuGet package only ships an implementation for Windows Phone, it does enable the consumption of the platform specific compression APIs in a portable fashion, which should include the Mono platforms.
Apparently there is a bug right now that prevents this from working. For more details see this question on Stack Overflow.
Upvotes: 2
Reputation: 5234
Follow Cheesebaron's advice and inject the functionality to PCL through an interface. For Android you can use Java.Util.Zip.ZipFile which is available through Xamarin's libraries.
Upvotes: 3
Reputation: 24470
Generally file handling won't work in PCL's as they know nothing about the underlying file system. So you will need some kind of file abstraction for each platform you intend to support. In MvvmCross you can do this by providing your own plugin for this. The PCL contains all the logic while the platform dependent projects do all the file processing sending the stream to your PCL.
You can read more about plugins here: https://github.com/MvvmCross/MvvmCross/wiki/MvvmCross-plugins
Upvotes: 4