Returing Virtual Directory Path From Web Application
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;
-
}
Related posts:
- Getting GAC Path Using Reflection
- Getting a SharePoint Field Value In C#
- Deploy a SharePoint Site Map by Applying Application Content to Local Server
- AspnetPathsCommands Partial Class
- Creating SecurityElement Objects from FileStream’s
1 Comment »
RSS feed for comments on this post. TrackBack URL























Articles & Research
SharePoint Architecture
Research Methodology
Personal/Off-Topic
Article Or Research Filed Under 

Thanks alot!
I have been looking for this for a few days. This has shortened my code totally.
Is there a way to obtain the Virtual Directory Path of an extended SharePoint web application ?
Thanks alot again,
Bobby.
Comment by Bobby — March 3, 2010 @ 4:23 pm