SharpDevelop Community

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

SharpZipLib issue while adding reference Windows Phone

Last post 09-23-2013 10:50 AM by ajaypunekar1. 10 replies.
Page 1 of 1 (11 items)
Sort Posts: Previous Next
  • 09-04-2013 8:56 AM

    SharpZipLib issue while adding reference Windows Phone

    I am trying to add dll of SharpZipLib to my Windows Phone 8 project. It gives me following error while adding

    a reference to a higher version or incompatible assembly cannot be added to the project

    Here is a screen shot

    Error

     

    Can some one please help me ? How can I solve this issue?

  • 09-04-2013 10:08 AM In reply to

    Re: SharpZipLib issue while adding reference Windows Phone

    Hi,

    Try the port at http://slsharpziplib.codeplex.com/

    Hope this will work - its for Win Phone 7 - please let me know if it works for Phone 8 !

    Thanks

    David

  • 09-04-2013 11:16 AM In reply to

    Re: SharpZipLib issue while adding reference Windows Phone

    I have use this. But there is an error while extracting the zip file which content images. I am getting this error Wrong Local header signature: 0xED33FAE9

    My code works perfect when zip file contain text files. It fails only when zip file contain images.

     

  • 09-04-2013 1:17 PM In reply to

    Re: SharpZipLib issue while adding reference Windows Phone

    I'm sure we can fix that if you can post your code here.

  • 09-04-2013 2:15 PM In reply to

    Re: SharpZipLib issue while adding reference Windows Phone

    Code is same for both zip files. It works perfect when a zip file contain text files, the issue occure when the zip files contain images. Is image bytes affect on it ?  

    Here I use this funcation to convert Bitmap image to byte array 

            public byte[ ] ConvertToBytes(BitmapImage bitmapImage)

            {

                byte[ data = null;

                WriteableBitmap wBitmap = null;

     

                using (MemoryStream stream = new MemoryStream())

                {

                    wBitmap = new WriteableBitmap(bitmapImage);

                    wBitmap.SaveJpeg(stream, wBitmap.PixelWidth, wBitmap.PixelHeight, 0, 100);

                    stream.Seek(0, SeekOrigin.Begin);

                    //data = stream.GetBuffer();

                    data = stream.ToArray();

                    DisposeImage(bitmapImage);               

                    return data;

                }                     

            }

            public void DisposeImage(BitmapImage image)

            {

                if (image != null)

                {

                    try

                    {

                        using (MemoryStream ms = new MemoryStream(new byte[ { 0x0 }))

                        {

                            image.SetSource(ms);

                        }

                    }

                    catch (Exception ex)

                    {

                    }

                }

            }

  • 09-05-2013 1:28 AM In reply to

    Re: SharpZipLib issue while adding reference Windows Phone

    Hi,

    Please post your entire code so we can investigate.

    Thanks, Dave

  • 09-05-2013 1:29 AM In reply to

    Re: SharpZipLib issue while adding reference Windows Phone

    Also, have you correctly diagnosed whether the problem is in writitng or reading the zip?

     

    Open your zip in WinZip and click File - Properties - Details. It will tell you if the zip is good or not.

  • 09-05-2013 6:41 AM In reply to

    Re: SharpZipLib issue while adding reference Windows Phone

    Thanks for reply. 

    When I upload a zip file of server, I download that file and unzip it. It's working perfect. I can unzip that file, see the all images. But the issue is in extracting the zip file in windows phone. Here is a code to unzip

     

    public static void UnzipAndSaveFiles(string filename, string outFolder)

            {

                try

                {

                    using (IsolatedStorageFile isoStore = IsolatedStorageFile.GetUserStoreForApplication())

                    {

                        using(IsolatedStorageFileStream stream = new IsolatedStorageFileStream(filename,FileMode.Open,isoStore))

                        {

                            using (var zipStream = new ZipInputStream(stream))

                            {

                                //For encrypted archives you can set password

                                //zipStream.Password = "godlike123";

                                ZipEntry entry;

     

                                while ((entry = zipStream.GetNextEntry()) != null)

                                {

                                    string fileName = Path.GetFileName(entry.Name);

     

     

                                    //check if entry is a file (it can be directory also)

                                    if (!string.IsNullOrEmpty(fileName))

                                    {

                                        //save file entry to storage

                                        using (var streamWriter =

                                            new BinaryWriter(new IsolatedStorageFileStream(fileName,

                                                                                            FileMode.Create,

                                                                                            FileAccess.Write, FileShare.Write,

                                                                                            isoStore)))

                                        {

                                            var buffer = new byte[2048];

                                            int size;

                                            while ((size = zipStream.Read(buffer, 0, buffer.Length)) > 0)

                                            {

                                                streamWriter.Write(buffer, 0, size);

                                            }

                                        }

                                    }

                                }

                            }

                        }

                        string[ files = isoStore.GetFileNames();

                        string[ directory = isoStore.GetDirectoryNames();

                    }

                }

                catch (Exception e)

                {

     

                }

            }

     

    On this line I am getting error while ((entry = zipStream.GetNextEntry()) != null)

  • 09-19-2013 7:58 AM In reply to

    Re: SharpZipLib issue while adding reference Windows Phone

    Hello Sir,

    Can you give me any example which collect the images from device(windows phone 8), create a zip file of that images and upload it on server. After uploading the zip file, download that file and extract that images folder in windows phone 8.

     

    Thank you. 

  • 09-23-2013 8:00 AM In reply to

    Re: SharpZipLib issue while adding reference Windows Phone

    Hi,

    The problem may be due to something happening to the zip file when retrieving it in Windows 8 Phone.

    How are you getting the file into the win8Phone? Are you downloading it directly from the server?

    Try a few things:

    - copy the problem zip from the Win8Phone to a PC and see it it works then or not

    - copy a good zip from a PC to the Win8Phone via USB or similar and see if it works

    - check the file size is correct on the phone

    This should help diagnose where the problems occurs.

     

  • 09-23-2013 10:50 AM In reply to

    Re: SharpZipLib issue while adding reference Windows Phone

    Hello,

    My problem is solved. What I did, just return the stream from web service to client instead of writing a byte in byte[ array and then pass that array.  Whatever byte I am getting from req.GetResponse().GetResponseStream(); return it to client. And problem solved.

     

    Thank you so much for help. :)

     

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