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 9172203
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T16:17:23+00:00 2026-06-17T16:17:23+00:00

I have a requirement where I have to download a zip file using c#

  • 0

I have a requirement where I have to download a zip file using c# (size can vary between 10mb – 400mb) from server based on input params. For example, download reports for userId = 10 and year = 2012.
The webserver accepts these two params and returns a zip file. How can I achieve this using WebClient class?
Thanks

  • 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-17T16:17:24+00:00Added an answer on June 17, 2026 at 4:17 pm

    You can do so by extending the WebClient class

    class ExtWebClient : WebClient
        {
    
            public NameValueCollection PostParam { get; set; }
    
            protected override WebRequest GetWebRequest(Uri address)
            {
                WebRequest tmprequest = base.GetWebRequest(address);
    
                HttpWebRequest request = tmprequest as HttpWebRequest;
    
                if (request != null && PostParam != null && PostParam.Count > 0)
                {
                    StringBuilder postBuilder = new StringBuilder();
                    request.Method = "POST";
                    //build the post string
    
                    for (int i = 0; i < PostParam.Count; i++)
                    {
                        postBuilder.AppendFormat("{0}={1}", Uri.EscapeDataString(PostParam.GetKey(i)),
                                                 Uri.EscapeDataString(PostParam.Get(i)));
                        if (i < PostParam.Count - 1)
                        {
                            postBuilder.Append("&");
                        }
                    }
                    byte[] postBytes = Encoding.ASCII.GetBytes(postBuilder.ToString());
                    request.ContentLength = postBytes.Length;
                    request.ContentType = "application/x-www-form-urlencoded";
    
                    var stream = request.GetRequestStream();
                    stream.Write(postBytes, 0, postBytes.Length);
                    stream.Close();
                    stream.Dispose();
    
                }
    
                return tmprequest;
            }
        }
    

    Usage : in case u have to create POST type request

    class Program
    {
        private static void Main()
        {
            ExtWebClient webclient = new ExtWebClient();
            webclient.PostParam = new NameValueCollection();
            webclient.PostParam["param1"] = "value1";
            webclient.PostParam["param2"] = "value2";
    
            webclient.DownloadFile("http://www.example.com/myfile.zip", @"C:\myfile.zip");
        }
    }
    

    Usage : for GET type request, u can simply use the Normal webclient

    class Program
    {
        private static void Main()
        {
            WebClient webclient = new WebClient();
    
            webclient.DownloadFile("http://www.example.com/myfile.zip?param1=value1&param2=value2", @"C:\myfile.zip");
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a requirement where i have to download file automatically from a web
I have a requirement to download multiple CSV files from a remote FTP site.
I have a requirement to download a PDF file and saving it on clicking
I have a 1GB binary file on another system. Requirement: ftp/download and convert binary
My requirement is that to download xml from server and save it into sd-card
I have a view that protects certain sensitive files from public download, using nginx'
We have a requirement to download multiple documents, zip them and allow user to
I have a requirement where I need to download binary file of a multimedia
I have requirement where in i want to download the files from different machines
I have requirement as following like showing ABPeoplePickerNavigationController in tabbar based application. I researched

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.