Untitled

mail@pastecode.io avatar
unknown
plain_text
3 years ago
1.3 kB
26
Indexable
Never
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 System.Net;
using System.IO.Compression;

namespace WindowsFormsApp3
{
    public partial class Form1 : Form
    {

        WebClient web = new WebClient();

        public Form1()
        {
            InitializeComponent();
        }

        private void DosyaIndirmeTamamlandiUyarisi(object sender, AsyncCompletedEventArgs e)
        {
            MessageBox.Show("Download Completed");
        }

        private void Download_Click(object sender, EventArgs e)
        {
            web.DownloadFileCompleted += new AsyncCompletedEventHandler(DosyaIndirmeTamamlandiUyarisi);

            Uri DosyaAdresi = new Uri(textBox1.Text);
            web.DownloadFileAsync(DosyaAdresi, textBox1.Text.Length.ToString()+".zip");

            string zipPath = @"C:\Users\Pc\source\repos\WindowsFormsApp3\WindowsFormsApp3\bin\Debug\34.zip";
            string extractPath = @"C:\Users\Pc\source\repos\WindowsFormsApp3\WindowsFormsApp3\bin\Debug\34";
            ZipFile.ExtractToDirectory(zipPath, extractPath);
        }
    }
}