title: Server.MapPath not working
body: <p>I'm trying to access files in a virtual directory I created in IIS for the first time but am getting weird results.</p>
  
  <p>OS: Windows XP Pro</p>
  
  <p>IIS: 5.1</p>
  
  <p>Development Platform:  Visual Studio 2008</p>
  
  <p>Language: C#</p>
  
  <p>Virtual Directory Name: portal</p>
  
  <p>Local Path: C:\digital_communications_report_portal</p>
  
  <p>Default Website Local Path: c:\inetpub\wwwroot</p>
  
  <p>I can download the file at <a href="http://localhost/portal/testFile.xlsx" rel="nofollow noreferrer">http://localhost/portal/testFile.xlsx</a> without any problem.</p>
  
  <p>I try either of these</p>
  
  <pre><code>string realFilename = Server.MapPath(ResolveUrl("~/portal/testFile.xlsx"));
  string realFilename = Server.MapPath(ResolveUrl("localhost/portal/testFile.xlsx"));
  </code></pre>
  
  <p>and get "C:\Documents and Settings\jjohnson\My Documents\Visual Studio 2008\WebSites\clientsite\localhost\portal\testFile.xlsx" which is my project path with the virtual path slapped on the end and is not a valid path. I try taking the tilde or localhost and I get a "Failed to map the path '/portal/testFile.xlsx'." exception.</p>
  
  <p>Any ideas what I'm doing wrong?</p>