List of Exercises

Webclient Download File in WinForms C#

	    
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;

namespace Download_File_from_Internet
{
  public partial class Form1 : Form
  {
    // C# Webclient Download a File from Internet by URL
    public Form1()
    {
      InitializeComponent();
    }

    private void download_Click(object sender, EventArgs e)
    {
      SaveFileDialog sfd = new SaveFileDialog();
      if (sfd.ShowDialog() == DialogResult.OK)
      {
        try
        {
          // Create a new WebClient instance.
          System.Net.WebClient myWebClient = new System.Net.WebClient();
          myWebClient.DownloadFile(textBox1.Text, sfd.FileName);
          MessageBox.Show("Is Downloaded!");
        }
        catch(Exception ex)
        { MessageBox.Show(ex.Message); }
      }
    }
  }
}
		
	 


Download the project of Visual Studio 2013 in DropBox Download


C# Webclient Download a File from Internet by URL in .Net Windows Application


Video Thumbnail