Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8607175
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T03:17:03+00:00 2026-06-12T03:17:03+00:00

I use these following codes to download a file from a specific url in

  • 0

I use these following codes to download a file from a specific url in C# windows application.

private void button1_Click(object sender, EventArgs e)
{
    string url = @"DOWNLOADLINK";
    WebClient web = new WebClient();
    web.DownloadFileCompleted += new AsyncCompletedEventHandler(web_DownloadFileCompleted);
    web.DownloadFile(new Uri(url), @"F:\a");
}

void web_DownloadFileCompleted(object sender, AsyncCompletedEventArgs e)
{
    MessageBox.Show("The file has been downloaded");
}

But it has an error for this line : web.DownloadFile(new Uri(url), @"F:\a");

It says :

An exception occurred during a WebClient request.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T03:17:04+00:00Added an answer on June 12, 2026 at 3:17 am

    No need for the event handler if you use DownloadFile rather than DownloadFileAsync.

    Update: From chat it turned out that the OP wanted the filename on the filesystem to reflect the filename specified at the end of the URL. This is the solution:

    private void button1_Click(object sender, EventArgs e)
    {
        Uri uri = new Uri("http://www.yourserver/path/to/yourfile.zip");
        string filename = Path.GetFileName(uri.LocalPath);
    
        WebClient web = new WebClient();
        web.DownloadFile(new Uri(url), Path.Combine(@"f:\", filename));
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to use these two classes from lucene - import org.apache.lucene.analysis.snowball.*; import org.apache.lucene.analysis.PorterStemmer;
So I'm trying to use these CSS3 buttons taken from: http://lab.simurai.com/buttons/ Here is the
I use the following code to stream large files from the Internet into a
I'm trying to download file from FTP using javascript, for which I created the
The following code doesn't work to download a file (btw clen is file's length):
How to get from C/C++ extension source code to a pyd file for windows
I have following use-case: there are several assemblies decorated with ProtoContract classes and I
I have the following use case: There's a class called Template and with that
I use node.js as REST API. There are following actions available: /contacts, GET, finds
Take the following article for example: http://weblogs.asp.net/psteele/archive/2009/11/23/use-dependency-injection-to-simplify-application-settings.aspx?utm_source=feedburner&utm_medium=feed&utm_campaign=Feed%3A+dotnetmvp+%28Patrick+Steele%27s+.NET+Blog%29 I don't see what benefit there is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.