-Hideki -Hideki  • 13.01.14 0:08

[C#] Gerenciador de Tarefas Empty [C#] Gerenciador de Tarefas 13.01.14 0:08

[C#] Gerenciador de Tarefas Mkto9Ts

Adicione:
2 Label
2 TextBox
2 Button
1 ProgressBar
1 folderBrowserDialog

Renomeie:
Label 1 >> Direct Link:
Label 2 >> Save File:

Button 1 >> Download
Button 2 >> Save File

De 2 cliques sobre o Form1 em cima de namespace vocês iram adicionar o seguinte codigo:

Código:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Net;
Depois de 2 cliques sobre o Button 1 e adicione o seguinte codigo:

Código:
if (textBox2.Text == String.Empty)//having a if statement to make the program more comfort
            {
                MessageBox.Show("Please selet a destination to save the file");
            }
            else
            {
                WebClient Download_Client = new WebClient();//Declaring the webclient as Download_Client
                Download_Client.DownloadFileCompleted += new AsyncCompletedEventHandler(Completed);//the event handler
                Download_Client.DownloadProgressChanged += new DownloadProgressChangedEventHandler(ProgressChanged);// " "
                Download_Client.DownloadFileAsync(new Uri(textBox1.Text.Trim().ToString()), textBox2.Text.Trim());// " "
            }
        }
Logo abaixo adicione:

Código:
private void ProgressChanged(object sender, DownloadProgressChangedEventArgs e)
        {
            progressBar1.Value = e.ProgressPercentage;//setting the progressbar value as downloadprogress
        }
        private void Completed(object sender, AsyncCompletedEventArgs e)
        {
            MessageBox.Show("Downloading Successful ", "Download_Completed", MessageBoxButtons.OK, MessageBoxIcon.Information);//just a messagebox         
            progressBar1.Value = (0);//resetting the progressbar
            textBox1.Text = "";//resetting the textbox
            textBox2.Text = "";// " "
        }
Agora de 2 cliques sobre o Button 2 e adicione o seguinte codigo:
Código:
FolderBrowserDialog Save = new FolderBrowserDialog();//Declaring the folder browsing dialog
            Save.RootFolder = Environment.SpecialFolder.Desktop;//setting to desktop
            if (Save.ShowDialog() == DialogResult.OK)//An if statement to to show the path in textbox
            {
                textBox2.Text = Save.SelectedPath;
            }
            string Text = textBox1.Text.ToString();//formatting to string
            string[] arry = Text.Split('/');//splitting /
            for (int i = 0; i < Int32.Parse(arry.Length.ToString()); i++)//a for loop here
            {
                if (i == Int32.Parse(arry.Length.ToString()) - 1)
                {
                    textBox2.Text += "\\" + arry[i].ToString();
                }
            }
        }

Créditos:

srDIEGO2014

WictorP WictorP  • 14.01.14 23:39

[C#] Gerenciador de Tarefas Empty Re: [C#] Gerenciador de Tarefas 14.01.14 23:39

Movido para Programação » C
Permissões neste sub-fórum
Não podes responder a tópicos

BH Servers

Recomendamos a BH Servers com proteção DDOS gratuita em Cloud Server de alta performance. Entrega imediata.