I have the following code for simple downloading a file using WebClient:

using System;
using System.Net;
using System.IO;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace DownloadManager
{
    public partial class Form1 : Form
    {
        public Form1()
        {

            InitializeComponent();

        }




        private void downloadbtn_Click(object sender, EventArgs e)
        {

            WebClient wc = new WebClient();

                wc.DownloadFile(this.downloadURL.Text, this.savePath.Text);



        }




    }
}

0ebd2d094acce1f0e3b48ae3114c83e7

Moreover, i have a form design:

a textbox to enter url (Name:downloadURL)

a textbox to set download path(Name:savePath)

a download button(Name:downloadbtn)

The issue is:

wc.DownloadFile(this.downloadURL.Text, this.savePath.Text);
returns

WebException unhandled

An exception occurred during a WebClient request.

How to fix it?

You haven't provided enough detail. What is the exception that you are receiving? What is the value of "downloadURL.Text"? Does the website require you to login to use it? Have you tried any other websites?

Edited 2 Years Ago by cgeier

What exception occured? This post is extremely vague, and I'd recommend explaining what errors/issues occured, not just "this issue occured, fix it please.

Have a great day!

This article has been dead for over six months. Start a new discussion instead.