web analytics

How to convert a relative or virtual path in an IIS server to the corresponding physical directory?

Options

codeling 1599 - 6654
@2016-01-21 11:32:22

The Server.MapPath property maps the specified relative or virtual path to the corresponding physical directory on the server.

protected void Application_Start(Object sender, EventArgs e)
{
 StreamReader sr = null;
 XmlDocument xmldoc = new XmlDocument();
 try
 {
  sr = new StreamReader(Server.MapPath("./Data/content.xml"));
  xmldoc.LoadXml(sr.ReadToEnd());
  //.....
  
 }
 finally
 {
  if (sr != null)
  {
    sr.Close();
  }
 }
}

Comments

You must Sign In to comment on this topic.


© 2024 Digcode.com