Save Paths, Virtual directories, and static locations
<p>I had a file upload that was uploading to a folder in the web application root, i.e. I had</p>

<pre><code>string savePath = @"~/documentation/"

string filename = Path.GetFileName(FileUploadControl.FileName);
FileUploadControl.SaveAs(Server.MapPath(savePath) + filename);
</code></pre>

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

<p>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</p>

<p>In Web.Config:</p>

<pre><code>&lt;appSettings&gt;
    &lt;add key="DocumentationLocation" value="C:\Documentation\" /&gt;
&lt;/appSettings&gt;
</code></pre>

<p>In the code:</p>

<pre><code>string savePath = ConfigurationSettings.AppSettings["DocumentationLocation"];

string filename = Path.GetFileName(FileUploadControl.FileName);
FileUploadControl.SaveAs(Server.MapPath(savePath) + filename);
</code></pre>

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

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

<blockquote>
  <p>'C:\TM_Documentation\' is not a valid virtual path.</p>
</blockquote>

<p>any idea what i'm doing wrong so that i can fix it and save the files outside of the web app directory? Thanks.  </p>
