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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T15:02:00+00:00 2026-05-28T15:02:00+00:00

I had a file upload that was uploading to a folder in the web

  • 0

I had a file upload that was uploading to a folder in the web application root, i.e. I had

string savePath = @"~/documentation/"

string filename = Path.GetFileName(FileUploadControl.FileName);
FileUploadControl.SaveAs(Server.MapPath(savePath) + filename);

and that worked fine, uploading the file to WebApp/documentation/filename.abc

The problem is, I want to change the documentation location so I don’t have to move that folder when pushing from development to production. So I did the following

In Web.Config:

<appSettings>
    <add key="DocumentationLocation" value="C:\Documentation\" />
</appSettings>

In the code:

string savePath = ConfigurationSettings.AppSettings["DocumentationLocation"];

string filename = Path.GetFileName(FileUploadControl.FileName);
FileUploadControl.SaveAs(Server.MapPath(savePath) + filename);

I figured this would work identically, saving the file to the folder specified in the web.config.

However, I get an error when I try to upload a document now, that says:

‘C:\TM_Documentation\’ is not a valid virtual path.

any idea what i’m doing wrong so that i can fix it and save the files outside of the web app directory? 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-05-28T15:02:02+00:00Added an answer on May 28, 2026 at 3:02 pm

    Remove the Server.MapPath(), you don’t need the server to map the path for you, because you are giving a full path already.

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

Sidebar

Related Questions

I had an application that was downloading a .CSV file from a password-protected website
I had a winforms C# class that internally was looking up a file.. to
I'm practicing some file upload with PHP and I was uploading a file numerous
I've got a method that uses a WebRequest to upload a file to a
I was using paperclip for file upload. with validations as below: validates_attachment_content_type :upload, :content_type=>['application/pdf'],
I had a huge file for creating this GUI and I have shortened it
If I had to following file on my development branch: # file.rb class Code
Imagine in the Global.asax.cs file I had an instance class as a private field.
I had created a zip file (together with directory) under Windows as follow (Code
In classic asp you had the Global.asa file, what's the equivalent in .Net? I

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.