SharpDevelop Community

Get your problems solved!
Welcome to SharpDevelop Community Sign in | Join | Help
in Search

Trying to use SharpZipLib to extract from a Silverlight .xap file

Last post 08-21-2008 9:37 PM by JohnReilly. 1 replies.
Page 1 of 1 (2 items)
Sort Posts: Previous Next
  • 08-10-2008 5:40 AM

    Trying to use SharpZipLib to extract from a Silverlight .xap file

    Hi,

     I am hitting my head at the wall and pulling my hair trying to figure out why since the xap format is a .zip file, I can't extract any files from it using the SharpZipLib (which by the way is great!). I get a message saying the compression method is not supported (256), I have tried to look for such a compression method but in the WinZip website mentions type 96 and 97 if I remember well, but nothing like 256.

     This is very confusing since even the windows explorer can view the contents of the xap file when it is renamed as a zip file. (I also did that before openning the file with my program). 

    The exact exception is:

                                                     "Library cannot extract this entry. Version required is (256)"

    Here is the C# code:

            private void UnpackDll(String pXapFileName)
            {
                // pXapFileName includes the whole Path, ex. "C:\XapFiles\xyz.xap"

                String sDllFullPath = pXapFileName.Replace(".zip", ".dll");
                String sDllName = Path.GetFileName(pXapFileName).Replace(".zip", ".dll");
                String sOutputDirectory = Path.GetDirectoryName(pXapFileName);
               

                ZipInputStream OZIS = new ZipInputStream(File.OpenRead(pXapFileName));

                ZipEntry OZE = OZIS.GetNextEntry();

                while (OZE != null)
                {
                    String sFileName = Path.GetFileName(OZE.Name);

                    if (sFileName == sDllName)
                    {
                        FileStream OFS = File.Create(sDllFullPath);
                        int iByteCounter = 2048;
                        Byte[ aBlock = new Byte[2048];

                        while (true)
                        {
                            iByteCounter = OZIS.Read(aBlock, 0, aBlock.Length);
                            if (iByteCounter > 0)
                            {
                                OFS.Write(aBlock, 0, iByteCounter);
                            }
                            else
                            {
                                break;
                            }
                        }
                    }

                    OZE = OZIS.GetNextEntry();
                }
            }

     

    Is it something I am doing wrong?  does SharpZipLib doesn't extract this kind of compression?  Is there any workaround or some small modification I can do to the source code in order to make it work?

    Any help will be greatly appreciated     

     Thanks in advance.

      

     

  • 08-21-2008 9:37 PM In reply to

    Re: Trying to use SharpZipLib to extract from a Silverlight .xap file

    Hi,

    The version required thing is a strong hint that "something is rotten in the state of Denmark" as some geezer once wrote.

    First off tweak your code to just dump the names/dates etc of the entries and  if that works it implies the version required to extract is non-standard.

    Your code is ok although its assuming thatthe entry it gets can be decompressed. Folder/directoriesand other oddballs like labels cannot be decompressed.

    hth, -jr-

Page 1 of 1 (2 items)
Powered by Community Server (Commercial Edition), by Telligent Systems
Don't contact us via this (fleischfalle@alphasierrapapa.com) email address.