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()



        private void downloadbtn_Click(object sender, EventArgs e)

            WebClient wc = new WebClient();

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




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);

WebException unhandled

An exception occurred during a WebClient request.

How to fix it?

Recommended Answers

All 5 Replies

But it still throwing the same exception!!!

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?

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!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.