Windows Forms: How to download multiple files in C#

This post shows you How to Download multiple files in parallel using C# .NET Windows Forms Application.

How to download a file from a URL in C#

Creating a new Windows Forms Application, then open your form designer. Next, You need to drag TextBox, ProgressBar, Label and Button controls from the Visual Studio Toolbox to your winform.

We will download a file from a url when you enter the url into the TextBox control. If you want to download multiple files, you need to set the TextBox to allow multiple lines, then you just need to use the loop to download each file.

We will create a simple UI that allows downloading multiple files in c# as shown below.

c# download multiple files

C# Download multiple files with progress bar

You can easily create a c# download file from server using the WebClient class without using any third party libraries.

Adding a click event handler to the Download button allows you to download multiple files concurrently in c#.

private async void btnDownload_Click(object sender, EventArgs e)
    using (FolderBrowserDialog fbd = new FolderBrowserDialog() { Description = "Select folder..." })
        if (fbd.ShowDialog() == DialogResult.OK)
            List<string> list = new List<string>(txtUrl.Text.Split(new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries));
            foreach (string url in list)
                using (WebClient client = new WebClient())
                    progressBar.Value = 0;
                    client.Credentials = CredentialCache.DefaultNetworkCredentials;
                    client.DownloadProgressChanged += Wc_DownloadProgressChanged;
                    Uri uri = new Uri(url);
                    string filename = System.IO.Path.GetFileName(uri.LocalPath);
                    await client.DownloadFileTaskAsync(uri,
            MessageBox.Show("You have finished downloading the file.", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information);

First, We will use FolderBrowserDialog to help you choose the path where you want to save the downloaded file, then make a c# download file from url to folder that you selected.

Adding a DownloadProgressChanged event handler allows you to update ProgressBar and Label controls.

private void Wc_DownloadProgressChanged(object sender, DownloadProgressChangedEventArgs e)
    progressBar.Value = e.ProgressPercentage;
    lblStatus.Invoke((MethodInvoker)(() => lblStatus.Text = $"{e.ProgressPercentage}%"));

To update the value to Label control in another thread you should use the Invoke method, otherwise you will encounter an error.

Through this example, you have learned how to download file c# windows forms with progress bar. It's a simple way to get file from server c#.