title: How to retrieve physical path for virtual directory
body: <p>I have a wcf web service deployed in IIS 7. When an error occurs I need to log the message that caused the error. The log needs to be created on a network share where developers have access to the share (as we do not have access to the server where the service is deployed). A virtual directory was created in IIS whose <strong>physical path</strong> is on the network share.</p>
  
  <p>How can I get the physical path of the virtual directory? I have tried using </p>
  
  <pre><code>System.Web.Hosting.HostingEnvironment.MapPath(virtualDirectoryPath)
  </code></pre>
  
  <p>but this just returns the physical path on the server where the service is located. </p>
  
  <p>For example, if the virtual directory is "WSLogs" and I give the virtualDirectoryPath as "~/WSLogs" I will get back C:\inetpub\wwwroot\myServiceDirectory\WSLogs\</p>