Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Programmatically get 14 hive path in sharepoint 2010

I need to get 14 hive path using code in C#.net.

can any one tell me how can I do this?

like image 996
Suresh Chaudhary Avatar asked Feb 09 '11 06:02

Suresh Chaudhary


1 Answers

You can access the physical path using SPUtility - the web path by looking at the SPWeb object.

Using SPUtility to get the SetupPath of Sharepoint like so:

using Microsoft.SharePoint.Utilities;
string spSetupPath = SPUtility.GetGenericSetupPath(string.Empty);
//e.g. returns "C:\Program Files\Common files\Microsoft Shared\Web Server Extensions\14
  • MSDN documentation SPUtility.GetGenericSetupPath
  • Example usages of SPUtility.GetGenericSetupPath (e.g. getting the templates dir)

Or you can use SPWeb's server relative URL method:

using Microsoft.Sharepoint;
string spServerURL = SPWeb.ServerRelativeUrl;

MSDN documentation SPWeb.ServerRelativeURL

Also have an overview of the Sharepoint 2010 14 hive structure.

like image 102
Dennis G Avatar answered Sep 20 '22 07:09

Dennis G