Stream compression not working

2 posts, 0 answers
  1. Syed
    Syed avatar
    9 posts
    Member since:
    Oct 2011

    Posted 12 Jul 2013 Link to this post

    Hi,

    we have requirement to generate zip file from list of images and allow it to download in Silverlight.
    All images are stored on remote machine(\\192.168.1.7\\abc\\\abc\year\month\1234\1234.jpg).
    so I have implemented functionality to get the list of images and passed it to wcf service as an argument
    and it returns list of byte array.
    I have implemented the below code to create the zip file from list of stream.
    busyIndicator.IsBusy = true;
                if (ListPic.Count > 0)
                {
                    //Save zip File
                    SaveFileDialog dialog = new SaveFileDialog();
                    dialog.Filter = "Zip File | *.zip";
                    bool? dialogResult = dialog.ShowDialog();
                    if (dialogResult == true)
                    {
                        using (ZipPackage zipPackage = ZipPackage.Create(dialog.OpenFile()))
                        {
     
                            foreach (PictureFile pic in ListPic)
                            {
                                Stream picStream = new MemoryStream(pic.PictureStream);
                                zipPackage.AddStream(picStream, System.IO.Path.GetFileName(pic.PictureName),ZipCompression.Deflated,DateTime.Now);
                                 
                            }
                        }
     
                         
                    }
                    busyIndicator.IsBusy = false;
                    this.DialogResult = false;

                     
                }
                else
                {
                    busyIndicator.IsBusy = false;
                    this.DialogResult = false;
                }

    In above code I have used to deflate compression to compress stream but it always returns the size and compression not works.
    Is there any more configuration required for compression to work?

    Thanks
    Rahul


  2. Tina Stancheva
    Admin
    Tina Stancheva avatar
    3298 posts

    Posted 17 Jul 2013 Link to this post

    Hi Rahul,

    Unfortunately just looking through your code, I can't see what might be going wrong. Can you try to isolate the issue in a sample solution and send it over? Or you can try to reproduce it in the sample solution I attached. It basically zips an xml file stream. If you can even extend it to demonstrate your issues, we'll be able to take a closer look at the issue.

    Regards,
    Tina Stancheva
    Telerik
    TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for SILVERLIGHT.
    Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
    Sign up for Free application insights >>
Back to Top