Sometimes we might need to programmatically retrieve the physical / local path of a web application and to achieve this we can use the code snippet provided below..
using (SPSite oSite = new SPSite("your site url")) { string physicalPath = oSite.WebApplication.IisSettings[SPUrlZone.Default].Path.ToString(); }
Over here we have taken an instance of our site and then trying to retrieve the physical path from the IIS setting property of the corresponding web application. The zone for retriving the IIS setting can be anything among “SPUrlZone.Default” / “SPUrlZone.Extranet” / “SPUrlZone.Internet” / “SPUrlZone.Intranet” depending on what we are looking for.