This is a migrated thread and some comments may be shown as answers.

Error with ZipPackage: Method not supported

9 Answers 200 Views
ZipLibrary
This is a migrated thread and some comments may be shown as answers.
Alexander
Top achievements
Rank 2
Alexander asked on 25 Jul 2011, 07:54 PM
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

9 Answers, 1 is accepted

Sort by
0
Viktor Tsvetkov
Telerik team
answered on 26 Jul 2011, 11:30 AM
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!

0
Alexander
Top achievements
Rank 2
answered on 26 Jul 2011, 02:12 PM
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);
            }
        }


0
Viktor Tsvetkov
Telerik team
answered on 26 Jul 2011, 03:10 PM
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!

0
Alexander
Top achievements
Rank 2
answered on 26 Jul 2011, 03:25 PM
I Can use in an ASP.net application? or the library is in the version telerik to asp.net?
0
Viktor Tsvetkov
Telerik team
answered on 26 Jul 2011, 05:03 PM
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!

0
Alexander
Top achievements
Rank 2
answered on 26 Jul 2011, 06:44 PM
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
0
Accepted
Viktor Tsvetkov
Telerik team
answered on 26 Jul 2011, 11:09 PM
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!

0
Alexander
Top achievements
Rank 2
answered on 27 Jul 2011, 01:57 PM
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.


0
Accepted
Viktor Tsvetkov
Telerik team
answered on 27 Jul 2011, 02:14 PM
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!

Tags
ZipLibrary
Asked by
Alexander
Top achievements
Rank 2
Answers by
Viktor Tsvetkov
Telerik team
Alexander
Top achievements
Rank 2
Share this question
or