1

Hi i am using Xamarin with c# to make an app that can zip and unzip files so after a few tries i found zipStorer.

http://zipstorer.codeplex.com/

Here is my code

 ZipStorer zip = ZipStorer.Open(Convert.ToString(Android.OS.Environment.GetExternalStoragePublicDirectory("BrSatisfacao/aaa.zip")), FileAccess.Read);

                List<ZipStorer.ZipFileEntry> dir = zip.ReadCentralDir();

                string path;

                foreach (ZipStorer.ZipFileEntry entry in dir)

                {

                    if (Path.GetFileName(entry.FilenameInZip) == "08.jpg")

                    {

                        path = Path.Combine(Convert.ToString(Android.OS.Environment.GetExternalStoragePublicDirectory("BrSatisfacao/")), Path.GetFileName(entry.FilenameInZip));

                        zip.ExtractFile(entry, Convert.ToString(Android.OS.Environment.GetExternalStoragePublicDirectory("BrSatisfacao/sample.jpg")));

                        break;

                    }   

                }

                zip.Close();

After a couple of hours the code is running fine and opening the zip and showing all in the console but no zip is being created... am i doing something wrong?

3
  • That code appears to be opening a zip an examining the contents. I don't see anything there that appears to create a new zip file.
    – Jason
    Nov 26, 2013 at 19:02
  • Give a read at the site of them, i get this impression too that i need to like Save(ZIP, Somewhere) but there is nothing like that, it says it doest it self and when u Close() the magic happens Nov 26, 2013 at 19:23
  • use Create() to create a new zip, and AddFile() to add files to a zip. You're doing neither of these things.
    – Jason
    Nov 26, 2013 at 19:26

1 Answer 1

1

Internally ZipStorer uses the character set 437 to do the encoding and un-encoding (line 85 in ZipStorer.cs):

    private static Encoding DefaultEncoding = Encoding.GetEncoding(437);

Xamarin does not include this character set by default when you build your application. As stated in the Localisation And Internationalisation document:

To reduce the size of the application, Xamarin.iOS doesn't include any specific encoding, and you have to instruct mtouch to include the assemblies containing the support for the encoding you need.

To include the character set, add the West character set through the internationalisation settings in your application:

enter image description here Ensure you check this for both Debug AND Release.

I could not get this to work for me when I was adding zip support to my application. In the end I rolled my own zip support by using the Java IO libraries but there may be a component available to add cross platform zip support.

1
  • Worked like a charm for me! But funny enough it was actually working on Debug mode... The problem started when I was packaging it.
    – Thpramos
    May 8, 2015 at 19:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.