Geekpedia Tutorials Home

Building a C# Chat Client and Server

Building a C# Chat Client and ServerA step by step tutorial teaching you how to create your own chat client and chat server easily in C#, for local networks or the Internet.

in C# Programming Tutorials

Getting Hard Drive Information

Getting Hard Drive InformationA C# tutorial showing you how to make use of WMI to extract information on disk drives, such as model, capacity, sectors and serial number.

in C# Programming Tutorials

UPS Shipping Calculator

UPS Shipping CalculatorThis tutorial will teach you how to calculate the shipping cost based on the weight, height, length and depth of the box, the distance and the UPS service type.

in PHP Programming Tutorials

Create Your Own Rich Text Editor

Create Your Own Rich Text EditorCreating a Rich Text Editor using JavaScript is easier to do than you might think, thanks to the support of modern browsers; this tutorial will walk you through it.

in JavaScript Programming Tutorials
Search
Tutorials
Programming Tutorials
IT Jobs
From CareerBuilder

Creating a download manager in C#

Learn how to create a download manager with a progress indicator in C# / .NET 2.0 using stream readers, web clients, web requests, buffers and more. You will also be learning the basics of threading in C#.

On Thursday, April 13th 2006 at 01:38 PM
By Andrew Pociu (View Profile)
*****   (Rated 4.7 with 65 votes)
Contextual Ads
More C# Resources
Advertisement
Download this Visual Studio 2005 project Download this project (Visual Studio 2005)

Download Manager Form

Sometime in 2004 on Geekpedia we saw a tutorial entitled Using WebClient to download a file, where we would use a few lines of code to save a file retrieved from the web through http on our hard drive. Now we're taking one step forward, to complicate the things just a little, so that we can display the progress of the download.
For displaying the progress we're going to use a ProgressBar and a Label. For calculating it, we'll need to retrieve the total size of the file from the web server, and calculate what we've downloaded by now.

This tutorial teaches you how to create a download manager in C# 2.0 (.NET Framework 2.0), using Visual Studio 2005. However, you can always convert this code to Visual Basic .NET, or to an earlier version of .NET Framework such as .NET 1.1.

Start by creating a C# Windows Application project in Visual Studio and on the form drag 3 labels, 2 textboxes, 2 buttons and one progressbar.

Download Manager Form

As you can see in the form above, the first two labels are just for describing the role of the first two textboxes which are named txtUrl and txtPath. They will obviously hold the URL of the file we want to download and the local path (and filename) to where we want to save it. The default values I set in the project will download a short video from Microsoft's Channel 9 website to C:\Filename.wmv.
The two buttons - btnDownload and btnStop - are used for starting and stopping a download, while the label below them - lblProgress - is used for showing the current progress of the download in bytes and percentage. Finally, the ProgressBar located at the bottom of the form is entitled prgDownload and it display the progress of the download on a scale from 1 to 100.

Now let's get into coding. Switch to code view, and the first thing we need to do is to add a few using statements for the namespaces we're going to use. Add the following 3 lines below the already existing using statements:

using System.Net;
using System.IO;
using System.Threading;


System.Net will be used for connecting to the web server, System.IO will be used for saving the file to the hard drive, and System.Threading will be used for the thread in which we're going to put the downloading process.

Inside the form's class, right above the constructor, add the following lines:

// The thread inside which the download happens
private Thread thrDownload;
// The stream of data retrieved from the web server
private Stream strResponse;
// The stream of data that we write to the harddrive
private Stream strLocal;
// The request to the web server for file information
private HttpWebRequest webRequest;
// The response from the web server containing information about the file
private HttpWebResponse webResponse;
// The progress of the download in percentage
private static int PercentProgress;

// The delegate which we will call from the thread to update the form
private delegate void UpdateProgessCallback(Int64 BytesRead, Int64 TotalBytes);


As you can see, we are creating a few objects that we're going to use later in the code. The object that stands out the most is not really an object, but a delegate: UpdateProgressCallback - this delegate will be used to call a method you'll see later in our code - UpdateProgress - from inside the thread. Because you see, from inside a thread we can't update the form elements directly (the label and the progress bar), so we need to create a delegate first, that takes the same arguments as the method. In our case the arguments are two Int64 variables that hold the number of bytes we downloaded from the server by now, and the number of total bytes the file has. Int64 is needed because this number can be really big.

Now let's review the biggest piece of the code. The one where the file actually gets downloaded. We'll put this code in a method called Download() which we're going to call in a thread when the download button is pressed. Here goes the method, below it there's more explanation of the code:

private void Download()
{
   using (WebClient wcDownload = new WebClient())
   {
      try
      {
         // Create a request to the file we are downloading
         webRequest = (HttpWebRequest)WebRequest.Create(txtUrl.Text);
         // Set default authentication for retrieving the file
         webRequest.Credentials = CredentialCache.DefaultCredentials;
         // Retrieve the response from the server
         webResponse = (HttpWebResponse)webRequest.GetResponse();
         // Ask the server for the file size and store it
         Int64 fileSize = webResponse.ContentLength;

         // Open the URL for download
         strResponse = wcDownload.OpenRead(txtUrl.Text);
         // Create a new file stream where we will be saving the data (local drive)
         strLocal = new FileStream(txtPath.Text, FileMode.Create, FileAccess.Write, FileShare.None);

         // It will store the current number of bytes we retrieved from the server
         int bytesSize = 0;
         // A buffer for storing and writing the data retrieved from the server
         byte[] downBuffer = new byte[2048];

         // Loop through the buffer until the buffer is empty
         while ((bytesSize = strResponse.Read(downBuffer, 0, downBuffer.Length)) > 0)
         {
            // Write the data from the buffer to the local hard drive
            strLocal.Write(downBuffer, 0, bytesSize);
            // Invoke the method that updates the form's label and progress bar
            this.Invoke(new UpdateProgessCallback(this.UpdateProgress), new object[] { strLocal.Length, fileSize });
         }
      }
      finally
      {
         // When the above code has ended, close the streams
         strResponse.Close();
         strLocal.Close();
      }
   }
}


The first line inside the method mentions that inside this method we'll be using the wcDownload object, which can be disposed after we're finished. If any error happens within the code, we have a finally block which closes the streams to prevent keeping a connection opened uselessly and to prevent the local file from being locked by the code.

Inside the try block we first retrieve information about the file using HttpWebRequest and HttpWebResponse objects. Note that some servers don't give information about the size of the file, case in which we can only download blindly. If the web server did not return any information regarding the size of the file, webResponse.ContentLength will return -1.

After we get the size of the file, we define the stream that retrieves the bytes from the server, and the stream that saves the file to the hard drive. Before starting to stream the bytes down the cables, we create a buffer where we store the data that is written to the hard drive file. The buffer is 2048 bytes in size, but you can change it to a different value if you prefer.

In the while loop we loop through the buffer and write the content of the buffer to the file on the local drive. We also use the Invoke method of the form to call UpdateProgressCallback (the delegate of UpdateProgress). In the array we pass two parameters that UpdateProgress accepts: how much we downloaded until now (by measuring the length of the local stream), and how big the total file is. If you don't have any knowledge of threading in C#, you probably would have guessed that you can update the form elements (labels, progress bars, etc.) directly, but for good enough reasons you can't.
If we were to call the Download() method directly, then we wouldn't have to use this.Invoke to call the UpdateProgress method. Speaking of UpdateProgress, let's see how this method looks like:

private void UpdateProgress(Int64 BytesRead, Int64 TotalBytes)
{
   // Calculate the download progress in percentages
   PercentProgress = Convert.ToInt32((BytesRead * 100) / TotalBytes);
   // Make progress on the progress bar
   prgDownload.Value = PercentProgress;
   // Display the current progress on the form
   lblProgress.Text = "Downloaded " + BytesRead + " out of " + TotalBytes + " (" + PercentProgress + "%)";
}


We do a simple math calculation to get the percentage (0 to 100) and we set it on the ProgressBar to reflect the progress. We also set the label with information on the progress of the download.

We're done with the methods for this application, now we only need to create the two event handlers for the Download and Stop buttons. Double clicking btnDownload in Visual Studio 2005 will create the Click event handler for you. Use the following code:

private void btnDownload_Click(object sender, EventArgs e)
{
   // Let the user know we are connecting to the server
   lblProgress.Text = "Download Starting";
   // Create a new thread that calls the Download() method
   thrDownload = new Thread(Download);
   // Start the thread, and thus call Download()
   thrDownload.Start();
}


In the code above we start a new thread, to which we pass the name of the method (without the parenthesis). Then we start the thread. The reason we need to use a thread and we can't just call the method from inside the Click event is because in that case our application would completely hang while downloading the file. It would become unusable and unresponsive, as if it crashed.

Finally, we have the code for the stop button:

private void btnStop_Click(object sender, EventArgs e)
{
   // Close the web response and the streams
   webResponse.Close();
   strResponse.Close();
   strLocal.Close();
   // Abort the thread that's downloading
   thrDownload.Abort();
   // Set the progress bar back to 0 and the label
   prgDownload.Value = 0;
   lblProgress.Text = "Download Stopped";
}


To make this a real download manager, we'd have to add resume options, and a download list so that we give the user the option to download multiple files at once, or schedule them. This will be covered in a future tutorial.

Below is the entire source code of Form1.cs that you can also view in the Visual Studio 2005 project files attached to this tutorial.

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

namespace DownloadManager
{
   public partial class Form1 : Form
   {
      // The thread inside which the download happens
      private Thread thrDownload;
      // The stream of data retrieved from the web server
      private Stream strResponse;
      // The stream of data that we write to the harddrive
      private Stream strLocal;
      // The request to the web server for file information
      private HttpWebRequest webRequest;
      // The response from the web server containing information about the file
      private HttpWebResponse webResponse;
      // The progress of the download in percentage
      private static int PercentProgress;

      // The delegate which we will call from the thread to update the form
      private delegate void UpdateProgessCallback(Int64 BytesRead, Int64 TotalBytes);

      public Form1()
      {
         InitializeComponent();
      }

      private void btnDownload_Click(object sender, EventArgs e)
      {
         // Let the user know we are connecting to the server
         lblProgress.Text = "Download Starting";
         // Create a new thread that calls the Download() method
         thrDownload = new Thread(Download);
         // Start the thread, and thus call Download()
         thrDownload.Start();
      }

      private void UpdateProgress(Int64 BytesRead, Int64 TotalBytes)
      {
         // Calculate the download progress in percentages
         PercentProgress = Convert.ToInt32((BytesRead * 100) / TotalBytes);
         // Make progress on the progress bar
         prgDownload.Value = PercentProgress;
         // Display the current progress on the form
         lblProgress.Text = "Downloaded " + BytesRead + " out of " + TotalBytes + " (" + PercentProgress + "%)";
      }

      private void Download()
      {
         using (WebClient wcDownload = new WebClient())
         {
            try
            {
               // Create a request to the file we are downloading
               webRequest = (HttpWebRequest)WebRequest.Create(txtUrl.Text);
               // Set default authentication for retrieving the file
               webRequest.Credentials = CredentialCache.DefaultCredentials;
               // Retrieve the response from the server
               webResponse = (HttpWebResponse)webRequest.GetResponse();
               // Ask the server for the file size and store it
               Int64 fileSize = webResponse.ContentLength;

               // Open the URL for download
               strResponse = wcDownload.OpenRead(txtUrl.Text);
               // Create a new file stream where we will be saving the data (local drive)
               strLocal = new FileStream(txtPath.Text, FileMode.Create, FileAccess.Write, FileShare.None);

               // It will store the current number of bytes we retrieved from the server
               int bytesSize = 0;
               // A buffer for storing and writing the data retrieved from the server
               byte[] downBuffer = new byte[2048];

               // Loop through the buffer until the buffer is empty
               while ((bytesSize = strResponse.Read(downBuffer, 0, downBuffer.Length)) > 0)
               {
                  // Write the data from the buffer to the local hard drive
                  strLocal.Write(downBuffer, 0, bytesSize);
                  // Invoke the method that updates the form's label and progress bar
                  this.Invoke(new UpdateProgessCallback(this.UpdateProgress), new object[] { strLocal.Length, fileSize });
               }
            }
            finally
            {
               // When the above code has ended, close the streams
               strResponse.Close();
               strLocal.Close();
            }
         }
      }

      private void btnStop_Click(object sender, EventArgs e)
      {
         // Close the web response and the streams
         webResponse.Close();
         strResponse.Close();
         strLocal.Close();
         // Abort the thread that's downloading
         thrDownload.Abort();
         // Set the progress bar back to 0 and the label
         prgDownload.Value = 0;
         lblProgress.Text = "Download Stopped";
      }
   }
}



You can now proceed to the second part of this tutorial, entitled Creating an advanced download manager in C#.
Digg Digg It!     Del.icio.us Del.icio.us     Reddit Reddit     StumbleUpon StumbleIt     Newsvine Newsvine     Furl Furl     BlinkList BlinkList

Rate Rate this tutorial
Comment Current Comments
by Joe on Friday, April 21st 2006 at 10:29 AM

The thread starting is not correct. You need to change the line:
thrDownload = new Thread(Download);
to:
thrDownload = new Thread(new ThreadStart(Download));

by Jacquers on Monday, June 26th 2006 at 04:53 AM

Awesome stuff!

Can't wait for the second part of the tutorial...
Is it also possible to add things like transfer speed & login to ftp sites?

by Mudassir Khan on Thursday, July 6th 2006 at 11:49 AM

The outstanding code I have ever seen.

by Johnny on Tuesday, July 18th 2006 at 06:12 AM

Waiting in anticipation of part 2 of the tutorial.... plz!

by zerospace on Friday, July 28th 2006 at 12:29 PM

i tried to convert it into visual studio.net, but it didn\'t work, anything particular i need to do?

by Horacio N. Hdez. on Sunday, August 20th 2006 at 11:52 AM

Joe - The Line is Correct, the New is Overloaded, it implicity creates a threadstart of a Method who had this sign ()

If any body want to check a blog in spanish about dotnet, check my
http://elblogdehoracio.blogspot.com

by Thomas on Saturday, September 2nd 2006 at 01:21 PM

Thanks man, awsome! Needed the thing badly...

by DM on Wednesday, September 6th 2006 at 04:02 AM

@zerospace:
I cannot see why the code in the class could not compile in VS.NET(v1.1 Framework). The only thing that will not compile is

using System.Collections.Generic; (Generics was only added in v2)

You \'might\' be able to just remove this line to get it to compile. I am unsure whether VS2005 uses Generics in the form designer.

by Huseyin Çakmak on Thursday, September 14th 2006 at 08:58 AM

Thank u man.It is very nice.I liked it.

by Joe on Tuesday, September 26th 2006 at 05:12 PM

In addition to the 2nd half of the tutorial, I'd love to see a download manager that is web-based.

by Nilesh on Friday, September 29th 2006 at 03:41 AM

I wnat to run this on windows 98. Does it work on windows 98?

by Andrei Pociu on Friday, September 29th 2006 at 01:33 PM

No, because you don't have .NET Framework on Windows 98.

by Andrei Pociu on Sunday, October 1st 2006 at 05:08 PM

I wrote a second part for this tutorial, in which you can pause and resume downloads; other improvements are done to the code too. It is entitled "Creating an advanced download manager in C#" and can be found at:
http://www.geekpedia.com/tutorial196_Creating-an-advanced-download-manager-in-Csharp.html

by Ken on Tuesday, February 13th 2007 at 07:35 AM

This was a really helpful article for me. I\'ve been writing a batch download program and I was getting a bit stuck with the progress bar idea.

Just one thing I would suggest. Once you get the file size from the HttpWebResponse object, it should probably be closed there and then. I ran into timeout issues with the second file in my batch. I isolated the closing of the web response and after I fixed that, all was good.

by felix on Thursday, May 3rd 2007 at 10:28 AM

http://www.geekpedia.com/tutorial179_Creating-a-download-manager-in-Csharp.html

by felix on Thursday, May 3rd 2007 at 10:30 AM

ups, wrong paste :P
here the correct one:
Hi, I have some trouble downloading bigger files. I tryed with a 40 MB file. and it freezes after 10% or so. And teh only think that keeps updating is the progress bar. but not the progress label.
the file is ultimately downloaded, but i dont want my app to freeze while downloading. What could i do?? thanks in advance!

by felix on Thursday, May 3rd 2007 at 10:33 AM

Hi, I have some trouble downloading bigger files. I tryed with a 40 MB file. and it freezes after 10% or so. And teh only think that keeps updating is the progress bar. but not the progress label.
the file is ultimately downloaded, but i dont want my app to freeze while downloading. Is there some solution?
I tryed the manager i downloaded here from the page.
Thanks in advance

by Andrei Pociu on Thursday, May 3rd 2007 at 10:56 PM

The progress bar is being updated at the same time as the progress label. Is there some specific way in which you are rendering the label? What happens if you invalidate the window (try minimizing and restoring it again)? Does it show the updated value then?

by XXX on Sunday, May 6th 2007 at 08:55 AM

Can it works in Visual Studio 2005 Express Edition?

by XXX on Sunday, May 6th 2007 at 08:57 AM

Can it works in Visual Studio 2005 Express Edition?

by Callen on Thursday, May 10th 2007 at 11:48 AM

Awesome tutorial, another thing you may look at is the BackgroundWorker class. It's much easier to program then setting up your own callbacks, and it has a built-in event and method to report progress to the form. Essentially they are the same things, but the documentation recommends the BackgroundWorker thread be used, so it may be worthwhile for anyone to consider.

by Ryan on Saturday, May 19th 2007 at 01:42 PM

I haven\'t tested yet, but watched to know if the stream created can be accessed. I want to use this to stream videos from the internet, and want to start the download and then have my application use the file being written to start playing the file.

Is this possible or will I get a read access error?

Thanks

by Andrei Pociu on Saturday, May 19th 2007 at 01:59 PM

It is possible to start playing the incomplete file, however WMP will lock it so I don't think you'll be able to continue writing to it.

You should have a look at Microsoft Windows Media Technologies, though.

by Ryan on Saturday, May 19th 2007 at 02:19 PM

Wow - quick response - thank you. I will try it out.

Also - I'm getting a compile error on "this.Invoke" - no definition. Any thoughts?

by Andrei Pociu on Saturday, May 19th 2007 at 03:58 PM

Try changing it to frmMain.Invoke().

by PL Turgeon on Monday, June 18th 2007 at 05:04 PM

If you experience any problems accessing the Download method multiple time in the same Thread, try closing the webResponse object in the try/catch/finaly: webResponse.Close();

My 2 cents!

by Andreas on Saturday, June 23rd 2007 at 07:39 AM

A very good tutorial!

by Zogger on Wednesday, July 4th 2007 at 08:55 AM

Not a bad tutorial, but the main problem for me is that it sends two requests to the server. I am using this code to access files from a website which increments a counter every time the file is requested, and therefore leads to an incorrect counter value.

There is however a fix, because the first request seems to be redundant. All it does is fetch the response headers which are available in the Stream object anyway. :)

by M.G.Thimmaiah on Friday, July 27th 2007 at 08:16 AM

File Download

by AbuMosaab on Tuesday, January 1st 2008 at 01:03 PM

Thanks for the excellent tutorial.

I have made a minor changing this:
// Create a request to the file we are downloading
webRequest = (HttpWebRequest)WebRequest.Create(txtUrl.Text);
// Set default authentication for retrieving the file
webRequest.Credentials = CredentialCache.DefaultCredentials;
// Retrieve the response from the server
webResponse = (HttpWebResponse)webRequest.GetResponse();
// Ask the server for the file size and store it
Int64 fileSize = webResponse.ContentLength;

// Open the URL for download
strResponse = wcDownload.OpenRead(txtUrl.Text);

To :
// Open the URL for download
strResponse = wcDownload.OpenRead(txtUrl.Text);
////////////////////////////
Int64 fileSize = Int64.Parse(wcDownload.ResponseHeaders[\"Content-Length\"]);

What do you think?

by Tushar on Thursday, January 10th 2008 at 12:45 AM

Hi i went throught the artical and there is no doubt it is good. But i have a question , when the thread is finished the control goes to Application(new Form1()); in the Program.cs page . why is that happening , that is actualy blocking me from going further rather it is taking me to appication start.

Any help will be greatly appreciated..

by Milind more on Saturday, March 15th 2008 at 02:07 AM

Hi this is milind working as software developer
Tahks for such a nice code Implementation is very good
Easy to undersatand

Thaks To greekpedia.com and his team

by Ashesh on Thursday, May 1st 2008 at 02:13 AM

Thanks for such a nice and clear tutorial. The best tutorial I found to understand how to safely do cross-threading communication.

by diags on Saturday, May 3rd 2008 at 07:48 AM

Hi,
I m facing a webexception...."Unable to connect to the remote server" in line webResponse = (HttpWebResponse)webRequest.GetResponse();

by Hammad Raza Khan on Friday, May 9th 2008 at 07:05 AM

have changed from

// Set default authentication for retrieving the file
webRequest.Credentials = CredentialCache.DefaultCredentials;


to


// Set default authentication for retrieving the file
webRequest.Proxy.Credentials = System.Net.CredentialCache.DefaultNetworkCredentials;

by Tharanga on Tuesday, July 15th 2008 at 11:48 AM

Hi I m trying to Develop this to Smart Device.So Any 1 Interested?

by serkopat on Wednesday, October 8th 2008 at 08:53 AM

great stuff thank you , will the codes work on windows mobile 5.0 and what should i do for writing downloadmanager on windows mobile.

by Chris on Thursday, November 20th 2008 at 09:34 AM

This is good to demonstrate a premise but the code could use a degree of refinement.

Make use of properties and accessors to separate interface logic and move some of the members into their proper place as local variables.

by selimhanov on Friday, November 21st 2008 at 08:24 AM

I'm glad that I found this, it helped me to create my first application in Visual C# Express Edition. But...
1. When I press Stop button, it stops and starts again. As a flash developer, I can guess, some handlers must be turned off.
2. I had an error during debugging... WebException was unhandled.
But still glad to be here.
Will be reading your comments with pleasure if I get them at my email.
P.S. Maybe it's because I was trying to download a 17 MB file?!

by selimhanov on Friday, November 21st 2008 at 09:01 AM

Solved the problem. The reason was... when I added the second button, I just pressed Ctrl and moved the Download button in order to duplicate it. But it seems it was a bad idea.
The rest is ok. Except, when during the debugging pressing Stop button, the debugger points to ...
while ((bytesSize = strResponse.Read(downBuffer, 0, downBuffer.Length)) > 0)
with the message IOException was unhandled
I guess, no error should appear when using final product, I mean outside debugger, because of using try . Am I wrong?!

by tommybui on Wednesday, February 11th 2009 at 08:32 PM

May i ask you one question?
How can you calculate :
private void UpdateProgress(Int64 BytesRead, Int64 TotalBytes)
{
// Calculate the download progress in percentages
PercentProgress = Convert.ToInt32((BytesRead * 100) / TotalBytes);
// Make progress on the progress bar
prgDownload.Value = PercentProgress;
// Display the current progress on the form
lblProgress.Text = "Downloaded " BytesRead " out of " TotalBytes " (" PercentProgress "%)";
}

by tommybui on Wednesday, February 11th 2009 at 08:33 PM

May i ask you one question?
How can you calculate :
private void UpdateProgress(Int64 BytesRead, Int64 TotalBytes)
{
// Calculate the download progress in percentages
PercentProgress = Convert.ToInt32((BytesRead * 100) / TotalBytes);
// Make progress on the progress bar
prgDownload.Value = PercentProgress;
// Display the current progress on the form
lblProgress.Text = "Downloaded " BytesRead " out of " TotalBytes " (" PercentProgress "%)";
}

by vipul on Monday, February 16th 2009 at 04:26 AM

Thanks for a well described article, that certainly help.

by MakiS on Wednesday, March 25th 2009 at 05:01 AM

hmhm very good tutorial,nC m8
but i want to start from a little more niwbie..xD
i try to do that with webClient
Example Code :
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Net;

namespace IDM
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

public void startBtn_Click(object sender, EventArgs e)
{
try
{

WebClient wc = new WebClient();
wc.DownloadStringCompleted = new DownloadStringCompletedEventHandler(wcFinish2);
wc.DownloadFileCompleted = new AsyncCompletedEventHandler(wcFinish2);

wc.DownloadProgressChanged =new DownloadProgressChangedEventHandler(wcChange);
wc.DownloadFile("http://mcsoft.no-ip.org:8080/upload/setup.exe", "C:/test/setup2.exe");
statusLB.Text = "Downloading " urlTx.Text;

}
catch (WebException f)
{
MessageBox.Show(f.Message);
}
}
public void wcFinish2(object sender,AsyncCompletedEventArgs e)
{
MessageBox.Show(e.UserState.ToString());

statusLB.Text = "Finish Downloading ,Path : " pathTx.Text;


}
public void wcChange(object sender, DownloadProgressChangedEventArgs e)
{
pb.Value ;
}
}
}

-----------------------------

but that dont works.. it downloads the file corretly but it doesnt show me the completed event , or the value ( the procress of downloading file..) if some1 know what happening and want to help me just send me an e-mail at : kataras2012@yahoo.gr/kataras2009@hotmail.com
or add me at msn : kataras2006@hotmail.com

i am thanking you

by MakIS on Wednesday, March 25th 2009 at 06:03 AM

ok... i find it :) but thnx
the code for more simply is :

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

namespace IDM
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

public void startBtn_Click(object sender, EventArgs e)
{

string fulluri = urlTx.Text fileTx.Text;
WebClient wc = new WebClient();

wc.DownloadFileCompleted = new AsyncCompletedEventHandler(completed);
wc.DownloadProgressChanged = new DownloadProgressChangedEventHandler(procress);
wc.DownloadFileAsync(new Uri(fulluri), (Application.StartupPath "/Downloads/" fileTx.Text));

statusLB.Text = "Downloading " fulluri;


}
public void procress(object sender, DownloadProgressChangedEventArgs e)
{

pb.Value = e.ProgressPercentage;
}
public void completed(object sender,AsyncCompletedEventArgs e)
{
statusLB.Text = "Download Completed!";
pathTx.Text = (Application.StartupPath "/Downloads/" fileTx.Text);

}
}
}

----------------

Just helping niewbies at net applications ( like me ;))

by tommybui on Friday, March 27th 2009 at 09:13 PM

i don't know how to program a download manager with fast download speed !!!

by MakiS on Saturday, March 28th 2009 at 09:06 AM

both of us we are niewbies at it...

we must work with HTTPWebRequests and WebResopsse..

but k...xD
i cant find one good tut for it.
but again ok

I have other problem.. if some1 knows how can i solve it
i want to publish my program
i have the Visual Studio 2008 Team Suite
( better than Professional)
but.. it doesn't work it
i make it and when i press Install ( after publishing at FTP or http( local with xampp) or FTP ( with freehostia,) or http and ftp by freehostia..
it tells me some

by MakiS on Saturday, March 28th 2009 at 09:06 AM

both of us we are niewbies at it...

we must work with HTTPWebRequests and WebResopsse..

but k...xD
i cant find one good tut for it.
but again ok

I have other problem.. if some1 knows how can i solve it
i want to publish my program
i have the Visual Studio 2008 Team Suite
( better than Professional)
but.. it doesn't work it
i make it and when i press Install ( after publishing at FTP or http( local with xampp) or FTP ( with freehostia,) or http and ftp by freehostia..
it tells me some

by Ankur on Wednesday, April 22nd 2009 at 07:27 AM

Sir firstly i would like to say that this is one of the best tutorial that i have ever seen ..

next is that ,here we can download the file from the different websites but sir ,problem arised for me when i downloaded the file from the youtube ,it has been downloaded very fastly but the downloaded file was not able to open due to the file extension of the downloaded file.so i changed the format (here in this case i changed to .flv) so it downloaded in flv format but my .flv player was unable to open the file ,infact any other player was unnable to open the file (as it was video file in .flv format) so what to do in this case please help me out...



and one more doubt ,suppose i want to download the file from the remote computer so how can i do that
because i gave the complete url of that but the run time error occured in the code given by you...

please reply me i am waiting for your response

by vinoth on Sunday, May 24th 2009 at 11:31 PM

This code is very good. how do i modify it. I need tolimit the size of the file if suppose the downloaded file exceeds predefined size means get authentication from admin then proceeds .Help meeeeeee

by vinoth on Sunday, May 24th 2009 at 11:34 PM

This code is very good. how do i modify it. I need tolimit the size of the file if suppose the downloaded file exceeds predefined size means get authentication from admin then proceeds .Help meeeeeee

by Johan Vandeplas on Thursday, June 4th 2009 at 08:13 AM

The idea is nice,

very clear, much comment etc.

To bad it isn't protected to any wrong input or wrong actions.

What if the url doesn't exist? Error
What if the pad isn't valid? Error
What if I runt it en simply push stop(before starting)? Error
What if I want to start a new download after downloading a file? Doesn't work.
What if I close the program during download? Error

And the list goes on...

Still thanks for another nice tutorial!

I'm planning on adding more functionality to this so I can use it in a school project.

(multiple download (by pasting 1 url / line in a textbox), added a folderBrowserDialog, option for x simultaneous downloads, added some validation/exception catching, display Gb / Mb / b in staid of thousands of bytes)

Keep up the good work!

by Johan Vandeplas on Thursday, June 4th 2009 at 10:54 AM

@vinoth:

you can get the filesize on about the 5th row of Download()

Int64 fileSize = webResponse.ContentLength;

maybe you can invoke a routine where you can ask for authentication and in the mean time pause the thread.

If authentication is valid, continue else abort tread.

by Lani on Wednesday, June 10th 2009 at 06:23 AM

very very thx ^^

i've ever tried to find large file downloading methods for my client.

good luck!!

by vimal on Saturday, July 18th 2009 at 03:32 AM

Hello to all,
can anybody tell me how can i display download remaining time....?

by sivana gaprasad on Saturday, August 8th 2009 at 08:01 PM

thank"U" brother for ur guidence for me this code is very useful to me and u have done an excellent job ......................Thank"U" once
again....tc bye

by david on Sunday, August 9th 2009 at 11:20 AM

Very nice.
I tried it but it doesn't saved the file.
The other things are working.
I'm using Visual Studio 2008.
But I'm realy thankful for this code.

by david on Sunday, August 9th 2009 at 11:20 AM

Very nice.
I tried it but it doesn't saved the file.
The other things are working.
I'm using Visual Studio 2008.
But I'm realy thankful for this code.

by Miroslav on Monday, September 7th 2009 at 01:30 PM

Great stuff, works like a charm...

by Xmen on Friday, September 18th 2009 at 01:14 PM

This could be done by WebClient with DownloadFileAsync() easily.

by Veena on Friday, September 18th 2009 at 01:48 PM

Hi,

Nice article.

Do you know how can I show upload progress just like download progress?

I don't find a way to know how much data is uploaded to the server, unless a complete upload happens.

Thanks you,

by Lucas on Friday, October 30th 2009 at 02:58 PM

Hello,

Great Code. But can anyone explain to me why does it sometimes freezes?
It's realy weird. It freezes for like 1 min, then the download is resumed, but the file is corrupted.

Thanks, Lucas

by sivanagaprasad on Monday, November 16th 2009 at 04:34 AM

plz send me the documentation of this project....
it is very useful to me.....

by sivanagaprasad on Monday, November 16th 2009 at 04:34 AM

plz send me the documentation of this project....
it is very useful to me.....

by sivanagaprasad on Monday, November 16th 2009 at 04:34 AM

plz send me the documentation of this project....
it is very useful to me.....

by smukov on Monday, November 16th 2009 at 06:15 AM

you have it on the top of the page, "download this project" link,if that is what you meant...
@ SivaNagaPrasad xD

by Xmen on Monday, November 16th 2009 at 07:34 AM

HOW THE F*CK UNSUBSCRIBE THIS SITE !? I DONT WANT ANY NOTIFICATION

by Blibla on Tuesday, November 24th 2009 at 12:43 PM

Thank you for nice Tutorial

by Shrijit on Monday, December 14th 2009 at 03:27 AM

good tuts man.
I also write tuts for people.
U can visit my blog :-
http://icancode.wordpress.com/

by sam on Friday, January 8th 2010 at 08:38 AM

will this download youtube videos ??? if not anyone can help me out in c# code to download flv files(youtube).

by gokul on Tuesday, February 2nd 2010 at 07:20 AM

Hi ,

I am working as developer , itz useful for beginners. thanks for a good work....

by Dilip on Wednesday, February 3rd 2010 at 02:26 AM

Thanks alot........
itz really helped me alot....

by nagaraju on Wednesday, March 24th 2010 at 01:57 PM

please send me the documentation

by ahmedalromema on Thursday, March 25th 2010 at 06:06 AM

i did teh above application but i face one problem when excuting the application and starding downloading a CSV file it gives me an error as below

(Value of '-26100' is not valid for 'Value'. 'Value' should be between 'minimum' and 'maximum')

by Jamie on Wednesday, March 31st 2010 at 05:46 PM

ahmedalromema

I am experiencing the same problem. Have you found a workaround yet? What version of .NET are you targeting?

Thanks

by Fullmetal on Sunday, May 2nd 2010 at 01:22 AM

Love this tut. I am using it in my program, but with some updates. instead of a form, I'm using it in a Windows vista/7 task dialog. Took me a while to figure out that it was crashing because i forgot the filename and extension and just game it a directory.

by anitha on Wednesday, June 23rd 2010 at 06:20 AM

access to path d:/ is denied
what can i do?

by KR4N3 on Monday, September 6th 2010 at 12:39 AM

I ran into a problem when I tried to run it:

while ((bytesSize = strResponse.Read(downBuffer, 0, downBuffer.Length)) > 0)
{
strLocal.Write(downBuffer, 0, bytesSize);

this.Invoke(new UpdateProgressCallBack(this.UpdateProgress), new object[] (strLocal.Length, fileSize));
}

When I try to run it I get this error: "Array must have array size or array initializer" or I get this message: "method name expected"

Could someone please help me fix this problem

by Johan Vandeplas on Monday, September 6th 2010 at 02:14 AM

Have you declared the delegate?

// The delegate which we will call from the thread to update the form
private delegate void UpdateProgessCallback(Int64 BytesRead, Int64 TotalBytes);

by Jack on Wednesday, December 22nd 2010 at 11:30 AM

Giving me access denied error.. what to do?

by Jack on Wednesday, December 22nd 2010 at 11:30 AM

Giving me access denied error.. what to do?

by Jack on Wednesday, December 22nd 2010 at 11:30 AM

Giving me access denied error.. what to do?

by Jack on Wednesday, December 22nd 2010 at 11:30 AM

Giving me access denied error.. what to do?

by Jack on Wednesday, December 22nd 2010 at 11:30 AM

Giving me access denied error.. what to do?

by Jack on Wednesday, December 22nd 2010 at 11:30 AM

Giving me access denied error.. what to do?

by ritima on Wednesday, December 29th 2010 at 01:46 AM

it is giiving me access denied error


"Access to the path 'D:\material' is denied."
tell me the solution please

by ritima on Wednesday, December 29th 2010 at 01:46 AM

it is giiving me access denied error


"Access to the path 'D:\material' is denied."
tell me the solution please

by Casper on Monday, January 10th 2011 at 12:59 PM

Good article for starters.

There are some redundant statements though and stopping a thread by calling Abort() is not doing it the right way. You need to call Join().
Some things are not done by the oo conventions, but it's functional and clear.

by Elad on Thursday, February 3rd 2011 at 03:10 AM

The access denied issue is caused by undefined file name.
The path string must specify the file name within it.

example: d:\test\myDownloadFile.txt

by Ruby on Wednesday, February 16th 2011 at 06:44 AM

The code is superb.
It helped me a lot to complete my upload task..
Thanku..

by Ruby on Wednesday, February 16th 2011 at 06:45 AM

The code is superb.
It helped me a lot to complete my upload task..
Thanku..

by Sarveshwar on Thursday, February 17th 2011 at 02:11 PM

Hi guys can anybody solve the following problem generated when I pressed download button;

the exception generated "Access to the path 'D:\' is denied." which is Microsoft.visualStudio.Debugger.Runtime.CrossThreadMessagingException'
Plz help me to resolve it. I am using Windows 7.
Is there is any way through this program I can set the accessibility to create the file which i wanted to download

by Sarveshwar on Thursday, February 17th 2011 at 02:11 PM

Hi guys can anybody solve the following problem generated when I pressed download button;

the exception generated "Access to the path 'D:\' is denied." which is Microsoft.visualStudio.Debugger.Runtime.CrossThreadMessagingException'
Plz help me to resolve it. I am using Windows 7.
Is there is any way through this program I can set the accessibility to create the file which i wanted to download

by anurag on Sunday, February 20th 2011 at 05:48 AM

great efforts
keep it up

by anurag on Sunday, February 20th 2011 at 05:49 AM

plz send me the documentation of this project....

by toanhoi on Wednesday, March 30th 2011 at 01:20 PM

Thanks you very much.I try to write a project to upload a file to Web but it does not.Can you help me,please?

by TechWarden on Monday, June 6th 2011 at 12:19 PM

This is fantastic! I know this tutorial is quite old but it is still the only one that got me on the right path to solving my problem!

Thank you Andrew! You are a scholar and a gentleman!

by mody on Thursday, June 30th 2011 at 07:47 PM

it's not work with me i don't know what is the problem please answer me that message box appear(the application stop work )

by saraswathi on Wednesday, September 28th 2011 at 10:27 AM

I need to subscribe to this site

by saraswathi on Wednesday, September 28th 2011 at 10:27 AM

I need to subscribe to this site

by saraswathi on Wednesday, September 28th 2011 at 10:27 AM

I need to subscribe to this site

by saraswathi on Wednesday, September 28th 2011 at 10:27 AM

I need to subscribe to this site

by free online dating on Sunday, November 20th 2011 at 06:43 AM

They have many quilted barbour jackets . And for men we have found barbour jacket that will offer comfort and practicality whilst remaining looking polished.

by Local SEO Consultants on Monday, December 12th 2011 at 05:45 AM

Put everything in a method, and in the catch block you can recall the method (you can say the method calls itself). Use System.Windows.Forms.Cursor.Position to get the cursor position in screen coordinates.I admire the important information you offer within your content. I'll bookmark your web site and have my kids examine up the following typically.

by GenF20 Plus on Tuesday, December 20th 2011 at 03:35 AM

Thanks a lot for providing individuals with a very wonderful possiblity to discover important secrets from this web site. It's always so enjoyable and as well , stuffed with a great time for me personally and my office colleagues to search your website at the least three times in a week to read the new stuff you have. And lastly, I'm so always fascinated with all the magnificent suggestions you give. Certain 4 tips in this article are particularly the very best we've ever had.

by Human Growth Hormone on Tuesday, December 20th 2011 at 03:37 AM

Thanks a lot for providing individuals with a very wonderful possiblity to discover important secrets from this web site. It's always so enjoyable and as well , stuffed with a great time for me personally and my office colleagues to search your website at the least three times in a week to read the new stuff you have. And lastly, I'm so always fascinated with all the magnificent suggestions you give. Certain 4 tips in this article are particularly the very best we've ever had.

by Phen375 on Tuesday, December 20th 2011 at 03:45 AM

Thanks a lot for providing individuals with a very wonderful possiblity to discover important secrets from this web site. It's always so enjoyable and as well , stuffed with a great time for me personally and my office colleagues to search your website at the least three times in a week to read the new stuff you have. And lastly, I'm so always fascinated with all the magnificent suggestions you give. Certain 4 tips in this article are particularly the very best we've ever had.

by Best Diet Pills on Tuesday, December 20th 2011 at 03:53 AM

Thanks a lot for providing individuals with a very wonderful possiblity to discover important secrets from this web site. It's always so enjoyable and as well , stuffed with a great time for me personally and my office colleagues to search your website at the least three times in a week to read the new stuff you have. And lastly, I'm so always fascinated with all the magnificent suggestions you give. Certain 4 tips in this article are particularly the very best we've ever had.

by Teeth Whitening on Tuesday, December 20th 2011 at 03:57 AM

Thanks a lot for providing individuals with a very wonderful possiblity to discover important secrets from this web site. It's always so enjoyable and as well , stuffed with a great time for me personally and my office colleagues to search your website at the least three times in a week to read the new stuff you have. And lastly, I'm so always fascinated with all the magnificent suggestions you give. Certain 4 tips in this article are particularly the very best we've ever had.

by Pure Acai Berry Max on Tuesday, December 20th 2011 at 03:59 AM

Thanks a lot for providing individuals with a very wonderful possiblity to discover important secrets from this web site. It's always so enjoyable and as well , stuffed with a great time for me personally and my office colleagues to search your website at the least three times in a week to read the new stuff you have. And lastly, I'm so always fascinated with all the magnificent suggestions you give. Certain 4 tips in this article are particularly the very best we've ever had.

by GenFX on Tuesday, December 20th 2011 at 04:03 AM

Thanks a lot for providing individuals with a very wonderful possiblity to discover important secrets from this web site. It's always so enjoyable and as well , stuffed with a great time for me personally and my office colleagues to search your website at the least three times in a week to read the new stuff you have. And lastly, I'm so always fascinated with all the magnificent suggestions you give. Certain 4 tips in this article are particularly the very best we've ever had.

by HGH Advanced on Tuesday, December 20th 2011 at 04:05 AM

Thanks a lot for providing individuals with a very wonderful possiblity to discover important secrets from this web site. It's always so enjoyable and as well , stuffed with a great time for me personally and my office colleagues to search your website at the least three times in a week to read the new stuff you have. And lastly, I'm so always fascinated with all the magnificent suggestions you give. Certain 4 tips in this article are particularly the very best we've ever had.

by batuockyo on Tuesday, December 20th 2011 at 04:05 AM

aaaaa

by Capsiplex on Tuesday, December 20th 2011 at 04:09 AM

Thanks a lot for providing individuals with a very wonderful possiblity to discover important secrets from this web site. It's always so enjoyable and as well , stuffed with a great time for me personally and my office colleagues to search your website at the least three times in a week to read the new stuff you have. And lastly, I'm so always fascinated with all the magnificent suggestions you give. Certain 4 tips in this article are particularly the very best we've ever had.

by Meratol on Tuesday, December 20th 2011 at 04:10 AM

Thanks a lot for providing individuals with a very wonderful possiblity to discover important secrets from this web site. It's always so enjoyable and as well , stuffed with a great time for me personally and my office colleagues to search your website at the least three times in a week to read the new stuff you have. And lastly, I'm so always fascinated with all the magnificent suggestions you give. Certain 4 tips in this article are particularly the very best we've ever had.

by Proactol Plus on Tuesday, December 20th 2011 at 04:25 AM

Thanks a lot for providing individuals with a very wonderful possiblity to discover important secrets from this web site. It's always so enjoyable and as well , stuffed with a great time for me personally and my office colleagues to search your website at the least three times in a week to read the new stuff you have. And lastly, I'm so always fascinated with all the magnificent suggestions you give. Certain 4 tips in this article are particularly the very best we've ever had.

by Nuratrim on Tuesday, December 20th 2011 at 04:27 AM

Thanks a lot for providing individuals with a very wonderful possiblity to discover important secrets from this web site. It's always so enjoyable and as well , stuffed with a great time for me personally and my office colleagues to search your website at the least three times in a week to read the new stuff you have. And lastly, I'm so always fascinated with all the magnificent suggestions you give. Certain 4 tips in this article are particularly the very best we've ever had.

by kimi on Tuesday, December 20th 2011 at 04:29 AM

How to hell do I unsubscribe?

by kimi on Tuesday, December 20th 2011 at 04:29 AM

How to hell do I unsubscribe?

by HGHAdvanced on Tuesday, December 20th 2011 at 02:44 PM

Thanks a lot for providing individuals with a very wonderful possiblity to discover important secrets from this web site. It's always so enjoyable and as well , stuffed with a great time for me personally and my office colleagues to search your website at the least three times in a week to read the new stuff you have. And lastly, I'm so always fascinated with all the magnificent suggestions you give. Certain 4 tips in this article are particularly the very best we've ever had.

by on Saturday, January 14th 2012 at 02:13 AM

Once you have recreated the problem and captured these steps, you can save them to a file and send it to your support person, who can then open it up and view

by HoldenJO25 on Monday, January 16th 2012 at 06:18 AM

According to my own investigation, billions of people on our planet get the personal loans at good creditors. Thence, there is great possibilities to receive a commercial loan in any country.

by gd poker gratis on Sunday, January 22nd 2012 at 03:46 PM

Fantastic beat ! I wish to apprentice while you amend your web site, how can i subscribe for a blog web site? The account aided me a acceptable deal. I had been a little bit acquainted of this your broadcast offered bright clear idea

by Programas de fidelizacion de clientes on Thursday, March 15th 2012 at 06:20 AM

Software para gestionar Programas fidelizacion clientes, Software fidelizacion clientes y Tarjetas de fidelizacion y puntos. Precios económicos. Consúltanos

by Anova Help on Friday, August 10th 2012 at 02:20 PM

Very good written post. It will be helpful to anyone who usess it, including me. Keep doing what you are doing - looking forward to more posts.

by Anupam on Saturday, August 11th 2012 at 04:11 PM

How to deploy the code.???

by Anupam on Saturday, August 11th 2012 at 04:36 PM

Getting an exception in:

strLocal = new FileStream(txtPath.Text, FileMode.Create, FileAccess.Write, FileShare.None);

It says that URI format is not supported.

by John Alex on Sunday, August 12th 2012 at 05:44 AM

Many people wish they had more confidence in themselves, whether it is related to their appearance, their abilities or both. If you can relate to this feeling, there is hope; you can take steps now to [url=http://findingmywhy.org/how-to-improve-self-confidence/][b]Improve your self-esteem[/b][/url] and change the way you are living your life. While these ideas may not give you all the answers, they are a great place to start.

by crashoverride on Monday, August 13th 2012 at 09:42 AM

it doesn't work.whenever i run it, it crashed.could you give me a suggestion?

by crashoverride on Monday, August 13th 2012 at 09:42 AM

it doesn't work.whenever i run it, it crashed.could you give me a suggestion?

by video conferencing technology on Tuesday, October 2nd 2012 at 02:48 AM

Switch to code view, and the first thing we need to do is to add a few using statements for the namespaces we're going to use. Add the following 3 lines below the already existing using statements:

by ali_khan on Wednesday, October 10th 2012 at 02:06 PM

Thanks for the help!!
i want to download all hyperlinks from a webpage.
like "www.'something'.com"
how can i modify the above one for links only.
Regards

by ali_khan on Wednesday, October 10th 2012 at 02:06 PM

Thanks for the help!!
i want to download all hyperlinks from a webpage.
like "www.'something'.com"
how can i modify the above one for links only.
Regards

by emergency water purification calculator on Thursday, October 25th 2012 at 01:59 AM

we're going to use. Add the following 3 lines below the already existing using statements:

by powdered milk nutrition on Thursday, November 1st 2012 at 05:55 AM

Add the following 3 lines below the already existing using statements:

by electric dog fence walmart on Saturday, November 3rd 2012 at 06:24 AM

If you are looking for cleaning service in london and sydney then i think you are on the right spot. you can contact us

by best mre menu on Monday, November 5th 2012 at 04:17 AM

so we need to create a delegate first, that takes the same arguments as the method. In our case the arguments are two Int64 variables that hold the number of bytes we downloaded from the server by now, and the number of total bytes the file has. Int64 is needed because this number can be really big.

by invisible fence installation rochester ny on Tuesday, November 6th 2012 at 02:36 AM

In our case the arguments are two Int64 variables that hold the number of bytes we downloaded from the server by now, and the number of total bytes the file has.

by nishant on Tuesday, January 15th 2013 at 05:40 AM

Error 2 The type 'download_manager.Form1' already contains a definition for 'Download'
Error 1 The type 'download_manager.Form1' already contains a definition for 'UpdateProgress'

I m getting these two errors what should i do ???
plz help


by nishant on Tuesday, January 15th 2013 at 05:40 AM

Error 2 The type 'download_manager.Form1' already contains a definition for 'Download'
Error 1 The type 'download_manager.Form1' already contains a definition for 'UpdateProgress'

I m getting these two errors what should i do ???
plz help


by nishant on Tuesday, January 15th 2013 at 05:40 AM

Error 2 The type 'download_manager.Form1' already contains a definition for 'Download'
Error 1 The type 'download_manager.Form1' already contains a definition for 'UpdateProgress'

I m getting these two errors what should i do ???
plz help


by nishant on Tuesday, January 15th 2013 at 05:40 AM

Error 2 The type 'download_manager.Form1' already contains a definition for 'Download'
Error 1 The type 'download_manager.Form1' already contains a definition for 'UpdateProgress'

I m getting these two errors what should i do ???
plz help


by nishant on Tuesday, January 15th 2013 at 05:40 AM

Error 2 The type 'download_manager.Form1' already contains a definition for 'Download'
Error 1 The type 'download_manager.Form1' already contains a definition for 'UpdateProgress'

I m getting these two errors what should i do ???
plz help


by nishant on Tuesday, January 15th 2013 at 05:40 AM

Error 2 The type 'download_manager.Form1' already contains a definition for 'Download'
Error 1 The type 'download_manager.Form1' already contains a definition for 'UpdateProgress'

I m getting these two errors what should i do ???
plz help


by shibbir on Monday, March 17th 2014 at 07:40 PM

Hi, it become works.

by towmes on Tuesday, April 8th 2014 at 05:55 PM

it doesn't working it show me this message:
( Access to the path 'D: eet.mp4' is denied.)

it refers to this line in code:
strLocal = new FileStream(txtBxPath.Text, FileMode.Create, FileAccess.Write, FileShare.None);

pls Help me.

by vikash on Thursday, May 15th 2014 at 10:36 AM

when i copy all the code in my project and run the application with url and patht then get error-
on this line
Value of -204800 is not valid for value.value should be between minimum and maximum
PercentProgress = Convert.ToInt32((BytesRead * 100) / TotalBytes);


Comment Comment on this tutorial
Name: Email:
Message:
Comment Related Tutorials
There are no related tutorials.

Comment Related Source Code
There is no related source code.

Jobs C# Job Search
My skills include:
Enter a City:

Select a State:


Advanced Search >>
Ads

From the creators of Geekpedia, a revolutionary new coupon website!

BargainEZ has coupons codes, printable coupons, bargains and it is the leading source of Passbook coupons for iPhone and iPod touch devices.

Coupons
Discover Geekpedia
Other Resources