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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T07:30:52+00:00 2026-05-20T07:30:52+00:00

First,I uploaded a file in a external server and got a url from that

  • 0

First,I uploaded a file in a external server and got a url from that server.Now i want to download that uploaded file from the external server through that url which i got from that server through asp.net and c#.
I wrote a c# code to download that file, but during that process i got an exception
“Exception of type ‘System.OutOfMemoryException’ was thrown”.
The following is the c# code which i wrote to download:

double dlsize=0;
string Url = "http://www.sample.com/download.zip"; \\File Size: 75MB
int lastindex = Url.LastIndexOf("/");
string TempUrlName = Url.Substring(lastindex + 1, Url.Length - (lastindex + 1));

WebRequest oWebRequest = WebRequest.Create(Url);
oWebRequest.Timeout = -1;
WebResponse oWebResponse = oWebRequest.GetResponse();

if (oWebResponse.ContentType != "text/html; charset=UTF-8")
{
    string myFile = oWebResponse.Headers.Get("Content-Length");
    int TempmyFile = Convert.ToInt32(myFile);
    double bytes_total = Convert.ToDouble(TempmyFile);
    dlSize = Convert.ToDouble(bytes_total / (1024 * 1024));

    System.IO.MemoryStream oMemoryStream = new MemoryStream();
    byte[] buffer = new byte[4096];

    using (System.IO.Stream oStream = oWebResponse.GetResponseStream())
    {
        int Count = 0;
        do
        {
            Count = oStream.Read(buffer, 0, buffer.Length);
            oMemoryStream.Write(buffer, 0, Count);
        } while (Count != 0);
    }

    System.IO.FileStream oFileStream = new System.IO.FileStream("C:\Documents and Settings\arun\Desktop\New Folder\download.zip", System.IO.FileMode.Create);
    oMemoryStream.WriteTo(oFileStream);
    oFileStream.Flush();
    oFileStream.Close();
    oMemoryStream.Flush();
    oMemoryStream.Close();
    oWebResponse.Close();
}
  • 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-20T07:30:53+00:00Added an answer on May 20, 2026 at 7:30 am

    It would be easier to do it like this:

    WebClient webClient = new WebClient();
    webClient.DownloadFile(remoteFileUrl, localFileName);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I just uploaded my first ASP.NET (as part of my learning of vb.net) and
Here's I want to do, I want to upload a file that will be
I have a Form that I am using to receive an uploaded .csv file,
I want to make sure a CSV file uploaded by one of our clients
Before saving an uploaded csv file I want to check it will parse. When
First of all, I'm uploading multiple images that goes through a for loop by
First off if you're unaware, samba or smb == Windows file sharing, \\computer\share etc.
First let me say that I really feel directionless on this question. I am
First off, I'm working on an app that's written such that some of your
I'm trying to rename a file after it's uploaded in the model's save method.

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.