3
The code is giving this error:
A first chance Exception of type 'Ionic.zip.Zipexception' occurred in Ionic.zip.dll
Additional information: Cannot read that as a ZipfileIf there is a Handler for this Exception, the program may be Safely continued.
Code:
using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using System.Windows.Forms;
    using Ionic.Zip;
    using System.Net;
    namespace WindowsFormsApplication1
    {
        public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
            }
            private void Form1_Load(object sender, System.EventArgs e)
            {
            }
            private void button1_Click(object sender, System.EventArgs e)
            {
                string pastaJogo = @"C:\Game\Play.exe";
                System.Diagnostics.Process.Start(pastaJogo);
                MessageBox.Show("Espere Um Pouco");
                Environment.Exit(0);
            }
            public void AUTOALIZAR_Click(object sender, EventArgs e)
            {
                WebClient wc = new WebClient();
                string fileSave = @"C:\Game\Play.zip";
                string zipFileSave = @"C:\Game\Play.zip";
                string zipFileSaveExtract = @"C:\Game";
                string downloadUrl = "https://www.dropbox.com/s/sq8s2bnyj5fqacv/plsay.zip?dl=1";
                MessageBox.Show("Esta Autoalizando...");
                wc.DownloadFileAsync(new Uri(downloadUrl), fileSave);
                wc.DownloadProgressChanged += new DownloadProgressChangedEventHandler(c_DownloadProgress);
                ZipFile zip = ZipFile.Read(zipFileSave);
                zip.ExtractAll(zipFileSaveExtract);
                wc.DownloadFileCompleted += new AsyncCompletedEventHandler(c_DownloadFileCompleted);
            } 
            public void c_DownloadProgress(object sender, DownloadProgressChangedEventArgs e)
            {
                int bytesin = int.Parse(e.BytesReceived.ToString());
                int totalbyte = int.Parse(e.TotalBytesToReceive.ToString());
                int kb1 = bytesin / 1024;
                int kb2 = totalbyte / 1024;
                progressBar1.Value = e.ProgressPercentage;
                label1.Text = kb1.ToString() + "KB Faltam " + kb2.ToString() + "KB " + e.ProgressPercentage.ToString() + "%";
            }
            public void c_DownloadFileCompleted(object sender, AsyncCompletedEventArgs e)
            {
                MessageBox.Show("Complete");
            }
            private void Exit_Click(object sender, EventArgs e)
            {
                Environment.Exit(0);
            }
        }
    }
Thank you, it’s working, but is it a normal mistake? error: Error 1 The type or namespace name 'Zipfile' does not exist in the namespace 'System.IO.Compression' (are you Missing an Assembly Reference?)
– Vralago
See here the specification of
ZipFile. Maybe we missed someusing.– Leonel Sanches da Silva