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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T05:36:43+00:00 2026-05-31T05:36:43+00:00

I’m using progressbar in c# but I got a bit of a problem I’m

  • 0

I’m using progressbar in c# but I got a bit of a problem I’m connecting to a server in our company and then I start to download an XML file from that 4k by 4k and showing this progress on a progressbar and for showing this if the file is below 100K till now then the maximum size of my progressbar would be 100 and if it changes I would change the maximum size of it to 1000 then 10000 and etc, so by this way I can doing this

progressbar1.value += 4;

So it’s somehow working, but as all you know the right solution is to know the size of the file my connection is going to download before starting to download that. I think a little and I think using Curl maybe solve the problem, but I don’t know exactly how to use it in C# or is there anyway to solve this problem.

Edit:
I’m downloading the file like this:

HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
            request.Credentials = new NetworkCredential(usr, pass);
            ServicePointManager.ServerCertificateValidationCallback = ((sender, certificate, chain, sslPolicyErrors) => true);
            HttpWebResponse response = (HttpWebResponse)request.GetResponse();
            StreamReader s = new StreamReader(response.GetResponseStream());
            int i = 0;
            int j = 0;
            int lastIndex = 0;
            int readNum = 0;
            Console.WriteLine("start at : " + DateTime.Now);
            while (!s.EndOfStream)
            {
                readNum = s.ReadBlock(temp, 0, 4096);
                if (w != null)
                    w.incByVolume(4);
                ret += new String(temp);
                temp = new char[4096];
            }

Thanks in advance…

  • 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-31T05:36:44+00:00Added an answer on May 31, 2026 at 5:36 am

    If you load it with HTTP(S) you can use WebClient.DownloadFileAsync which has all you need:

    WebClient webClient = new WebClient();
    webClient.DownloadProgressChanged += (s, args) =>
    {
        //args.BytesReceived, args.TotalBytesToReceive and args.ProgressPercentage will have all you need
    };
    webClient.DownloadFileCompleted += (s, args) =>
    {
        //done
    };
    webClient.DownloadFileAsync(new Uri(remoteFile), localFile);
    // or the following if you want it in memory:
    webClient.DownloadStringCompleted += (s, args) => 
    {
        //done, see args.Result for the string
    };
    webClient.DownloadStringAsync(new Uri(remoteFile));
    

    If you need credentials to acces the page, you can use the Credentials property of the WebClient.

    According to the notes on WebClient:

    By default, the .NET Framework supports URIs that begin with http:, https:, ftp:, and file: scheme identifiers.

    So it would even work with loading the file from a share using the file: identifier.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We are using XSLT to translate a RIXML file to XML. Our RIXML contains
We're building an app, our first using Rails 3, and we're having to build
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
That's pretty much it. I'm using Nokogiri to scrape a web page what has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
I am reading a book about Javascript and jQuery and using one of the
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace
Specifically, suppose I start with the string string =hello \'i am \' me And

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.