Posted by Adam Buenz
If you consume a SPWebApplication object as a parameter, you can return the virtual directory path by using the GetIisSettingsWithFallback() method to return the settings for a specified SharePoint zone.
Here is a static method that demonstrates how to do it:
C#:
-
public static string GetVirtualDirectoryPath(SPWebApplication webApp)
-
{
-
string path = string.Empty;
-
try
-
{
-
if (webApp != null)
-
{
-
path = webApp.GetIisSettingsWithFallback(SPUrlZone.Default).Path.ToString();
-
}
-
}
-
catch (Exception exception)
-
{
-
-
}
-
return path;
-
}










