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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T21:45:11+00:00 2026-06-11T21:45:11+00:00

For a web application I’m currently working on, I want to download a file

  • 0

For a web application I’m currently working on, I want to download a file from internet to my web server.
I can use below code to download the file to the web server’s hard drive, what should I set to the destination path to get this working. We are planing to host this site in a shared hosting environment.

using System.Net;

using(var client = new WebClient())
{
    client.DownloadFile("http://file.com/file.txt", @"C:\file.txt");
}
  • 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-11T21:45:12+00:00Added an answer on June 11, 2026 at 9:45 pm

    I think common way to do it is this:

    string appdataFolder = AppDomain.CurrentDomain.GetData("DataDirectory").ToString();
    

    or

    string appdataFolder = System.Web.HttpContext.Current.Server.MapPath(@"~/App_Data");
    

    Also notice, that WebClient class implements IDisposable, so you should use dispose or using struct.
    And I eager you to read some naming convention for c# (local variables usually start with lower case letter).

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

Sidebar

Related Questions

In web application [asp.net] shall we write code that can retrive data from datbase
The web application I'm currently developing supports CSV export from (using SELECT INTO OUTFILE)
My web application lets user import an excel file and writes the data from
If web application and SQL Server are on different machines(both running Windows) on intranet,
The web application I'm working on serves up images with URLs like /image?name=a.gif. Pages
The web application im working on has a few custom attributes on HTML elements
My Web application makes use of Ext JS & Java web technology. Due to
The web application we are developing allows developers to do an HTTP POST from
In web application, I fetch the data from back end and the data is
My web application is composed of several Visual Studio projects. It currently runs fine

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.