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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T22:40:05+00:00 2026-06-05T22:40:05+00:00

My code here works fine to get the content length, and tells me how

  • 0

My code here works fine to get the content length, and tells me how big the file is, then it works on the if statement. Just for some reason after the if statement, if the MB is less than 5, it won’t download the file, it just stops the program in general. It’s like after the HTTP Request, it just stops. So I don’t know if it’s my codes fault, or if something else, if this is a stupid question, my apologies.

            byte[] test;
            int size;
            long MB = 0;
            HttpWebRequest req = (HttpWebRequest)WebRequest.Create(Path);
            req.Method = "HEAD";
            HttpWebResponse resp = (HttpWebResponse)(req.GetResponse());
            long len = resp.ContentLength;
            MB = len / 1048576;

            if (MB > 5)
            {
                Console.WriteLine("File to big!");
            }
            else
            {
                var webClient = new WebClient();
                MemoryStream ms = new MemoryStream();
                byte[] imageBytes = webClient.DownloadData(Path);
                test = imageBytes;
                size = test.Length;
            }
  • 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-05T22:40:07+00:00Added an answer on June 5, 2026 at 10:40 pm

    Just guessing, but perhaps calling resp.Close(); prior to attempting to open another connection would help?

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

Sidebar

Related Questions

I have my code here, it works fine from my home, where my user
I have some code here which works perfectly in firefox but not in chrome
I've got some code here that works great on IPv4 machines, but on our
Here is my simple code, which works fine if called from php or any
The Problem: Locally my application works fine. My HTTP GET returns code 200 and
I got some sample code from the net here: http://www.javadb.com/sending-a-post-request-with-parameters-from-a-java-class That works fine. It
here is my old code which works: $('.logo').hover(function(){ $(this).addClass('animated swing')}, function(){$(this).removeClass('animated swing') }); here
Here is a code excerpt from AspComet project that works with Autofac. public MessageBus(IClientRepository
Here is the code in a function I'm trying to revise. This example works
Site here . Why is it that the code works for $('#club').change(function(event) but not

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.