Error with ZipPackage: Method not supported

10 posts, 2 answers
  1. Alexander Jimenez
    Alexander Jimenez avatar
    11 posts
    Member since:
    Sep 2009

    Posted 25 Jul 2011 Link to this post

    I'm downloading a ZIP file handler and do a verification with the ZipPackage and gives me a method not supported error

    My code:
    request.BeginGetResponse(result =>
                        {
                            var response = request.EndGetResponse(result) as HttpWebResponse;
                            try
                            {                           
                              //  StreamResourceInfo info = new StreamResourceInfo(response.GetResponseStream(), null);
                                //StreamResourceInfo zip = Application.GetResourceStream(info, new Uri("datos", UriKind.RelativeOrAbsolute));
                                Stream info = response.GetResponseStream();
                               
                                if (ZipPackage.IsZipFile(info))
                                {
                                    using (ZipPackage zipPackage = ZipPackage.Open(info, FileAccess.Read))
                                    {
                                        ZipPackageEntry zip = zipPackage.ZipPackageEntries[0];
                                        using (Stream responseStream = zip.OpenInputStream())
                                        {
                                            using (StreamReader reader = new StreamReader(responseStream))
                                            {
                                                string texto = reader.ReadToEnd();
                                                lista = JsonConvert.DeserializeObject<List<Reportes>>(texto);
                                                dis.BeginInvoke(new AddtoLista(LlenarLista), lista);
     
                                                reader.Close();
                                                responseStream.Close();
                                            }
                                        }
                                    }
                                }
                            }
                            catch (Exception ex)
                            {
     
                                throw ex;
                            }
                        }, null);

    Thank you very much in advance
  2. Viktor Tsvetkov
    Admin
    Viktor Tsvetkov avatar
    382 posts

    Posted 26 Jul 2011 Link to this post

    Hello Alexander Jimenez,

    Could you please elaborate a bit more on this issue and tell us what compression tool is used to create the zip file or could you send us the file that is causing the problems?

    Greetings,
    Viktor Tsvetkov
    the Telerik team

    Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

  3. Alexander Jimenez
    Alexander Jimenez avatar
    11 posts
    Member since:
    Sep 2009

    Posted 26 Jul 2011 Link to this post

    have a Handler that receives a few parameters for a query to the database, this returns a collection of data and it is converted to a JSON through library Newtonsoft.Json (http://json.codeplex.com/) then indicated you the handler the new contentType "application/zip"

    And finally I compress it with the Ionic.Zip library (http://dotnetzip.codeplex.com/)


    Code in the Handler
    public void ProcessRequest(HttpContext context)
            {
                string texto = new StreamReader(context.Request.InputStream).ReadToEnd();
                ParametrosReportes paramJSON = Newtonsoft.Json.JsonConvert.DeserializeObject<ParametrosReportes>(texto);
                string dataJSON =string.Empty;
                if (paramJSON != null)               
                    dataJSON =Newtonsoft.Json.JsonConvert.SerializeObject(ReportesMetodos.ObtenerReporte(conexion, paramJSON));
                else
                    dataJSON = Newtonsoft.Json.JsonConvert.SerializeObject(ReportesMetodos.ObtenerReporte(conexion, new ParametrosReportes() { OrdendelReporte = OrdenarPor.Fecha, FechaInicial = DateTime.Now.ToString("dd/MM/yyyy"), FechaFinal = DateTime.Now.ToString("dd/MM/yyyy"), Tabla="0" }));
       
                string archiveName = String.Format("archive-{0}.zip", DateTime.Now.ToString("yyyy-MMM-dd-HHmmss"));
                context.Response.ContentType = "application/zip";
                context.Response.AddHeader("content-disposition", "filename=" + archiveName);
                 
     
                using (Ionic.Zip.ZipFile zip = new Ionic.Zip.ZipFile())
                {
                    zip.AddEntry("datos", dataJSON);
                    zip.Save(context.Response.OutputStream);
                }
            }


  4. Viktor Tsvetkov
    Admin
    Viktor Tsvetkov avatar
    382 posts

    Posted 26 Jul 2011 Link to this post

    Hello Alexander Jimenez,

    ZipPackage works only with standard zip files and does not support other similar formats such as gzip, zip2, tar or rar. You can simply use the ZipPackage not only for the decompression, but also for the compression. If you have further questions feel free to ask.

    Greetings,
    Viktor Tsvetkov
    the Telerik team

    Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

  5. Alexander Jimenez
    Alexander Jimenez avatar
    11 posts
    Member since:
    Sep 2009

    Posted 26 Jul 2011 Link to this post

    I Can use in an ASP.net application? or the library is in the version telerik to asp.net?
  6. Viktor Tsvetkov
    Admin
    Viktor Tsvetkov avatar
    382 posts

    Posted 26 Jul 2011 Link to this post

    Hello Alexander Jimenez,

    Please accept my apologies for the misleading, I didn't notice that it is an ASP.NET application. Actually I tried to reproduce your issue, created a zip file using the Ionic.Zip library and added a string entry to it. Then I opened it with the ZipPackage and had no problem while reading the entry. So I am not sure what exactly causes the problem in your application. Could you please try some different scenario using the Ionic.Zip and the ZipPackage or try to simplify your project and send it to us, so we will be able to better investigate the problem?

    Kind regards,
    Viktor Tsvetkov
    the Telerik team

    Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

  7. Alexander Jimenez
    Alexander Jimenez avatar
    11 posts
    Member since:
    Sep 2009

    Posted 26 Jul 2011 Link to this post

    Here I am sending a sample project as I am using your library. Any commentsplease tell me.
    You can download it from this URL: File to Download
  8. Answer
    Viktor Tsvetkov
    Admin
    Viktor Tsvetkov avatar
    382 posts

    Posted 26 Jul 2011 Link to this post

    Hi Alexander Jimenez,

    Could you please examine the modified project and tell me if it works for you?

    All the best,
    Viktor Tsvetkov
    the Telerik team

    Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

  9. Alexander Jimenez
    Alexander Jimenez avatar
    11 posts
    Member since:
    Sep 2009

    Posted 27 Jul 2011 Link to this post

    Sorry Zip_Lib the project was not within the ZIP file that sent me.

    But looking closely I saw some changes to it and I am working, I assume that the project that I lack the time to open the solution you sent me the same dll Telerik.Windows.Zip

    Thank you very much for your attention.


  10. Answer
    Viktor Tsvetkov
    Admin
    Viktor Tsvetkov avatar
    382 posts

    Posted 27 Jul 2011 Link to this post

    Hello Alexander Jimenez,

    Accept my apologies, this project shouldn't be included, but instead you should add your Telerik.Windows.Zip.dll.

    Greetings,
    Viktor Tsvetkov
    the Telerik team

    Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

Back to Top