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

  • SEARCH
  • Home
  • 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 987585
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T05:30:10+00:00 2026-05-16T05:30:10+00:00

Alright, I have ran into a problem when using DownloadDataAsync and having it return

  • 0

Alright, I have ran into a problem when using DownloadDataAsync and having it return the bytes to me. This is the code I am using:

    private void button1_Click(object sender, EventArgs e)
    {
        byte[] bytes;
        using (WebClient client = new WebClient())
        {
            client.DownloadProgressChanged += new DownloadProgressChangedEventHandler(DownloadProgressChanged);
            bytes = client.DownloadDataAsync(new Uri("http://example.net/file.exe"));
        }
    }
    void DownloadProgressChanged(object sender, DownloadProgressChangedEventArgs e)
    {
        double bytesIn = double.Parse(e.BytesReceived.ToString());
        double totalBytes = double.Parse(e.TotalBytesToReceive.ToString());
        double percentage = bytesIn / totalBytes * 100;
        label1.Text = Math.Round(bytesIn / 1000) + " / " + Math.Round(totalBytes / 1000);

        progressBar1.Value = int.Parse(Math.Truncate(percentage).ToString());
        if (progressBar1.Value == 100)
        {
            MessageBox.Show("Download Completed");
            button2.Enabled = true;
        }
    }

The error I get is “Cannot implicitly convert type ‘void’ to ‘byte[]'”

Is there anyway I can make this possible and give me the bytes after it is done downloading? It works fine when removing “bytes =”.

  • 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-05-16T05:30:11+00:00Added an answer on May 16, 2026 at 5:30 am

    Since the DownloadDataAsync method is asynchronous, it doesn’t return an immediate result. You need to handle the DownloadDataCompleted event :

    client.DownloadDataCompleted += new DownloadDataCompletedEventHandler(DownloadCompleted);
    ...
    
    
    private static void DownloadCompleted(Object sender, DownloadDataCompletedEventArgs e)
    {
        byte[] bytes = e.Result;
        // do something with the bytes
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 539k
  • Answers 539k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer You could write your own extension to the TextField class… May 17, 2026 at 2:13 am
  • Editorial Team
    Editorial Team added an answer I guess its just a matter of preference. Personally I… May 17, 2026 at 2:12 am
  • Editorial Team
    Editorial Team added an answer Would I place conditional statements within the __set method to… May 17, 2026 at 2:12 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

I recently started programming my first Cocoa app. I have ran into a problem
Alright I have an xml document that looks something like this: <xml> <list> <partner>
Alright I have two problems. I'm using AVAudioPlayer to play a simple audio file
Alright im doing a site which is available in multiple languages. I have ran
Alright I have a CSS liquid div based layout for my personal web site.
Alright I have two loops going, on in the body and on in the
Alright, I have been doing the following (variable names have been changed): FileInputStream fis
Alright, I have a div which is 50px (height), and the width does not
Alright, I have library I wrote in C that reads a file and provides
Alright, I have a fairly simple design. class Update(models.Model): pub_date = models.DateField() title =

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.