以编程方式在sharepoint 2010中获得14个配置单元路径

Sur*_*ary 11 sharepoint-2010

我需要使用C#.net中的代码获得14个hive路径.

谁能告诉我怎么能这样做?

Den*_*s G 15

您可以使用SPUtility- 通过查看SPWeb对象的Web路径来访问物理路径.

使用SPUtility得到了SharePoint的SetupPath像这样:

using Microsoft.SharePoint.Utilities;
string spSetupPath = SPUtility.GetGenericSetupPath(string.Empty);
//e.g. returns "C:\Program Files\Common files\Microsoft Shared\Web Server Extensions\14
Run Code Online (Sandbox Code Playgroud)

或者您可以使用SPWeb的服务器相对URL方法:

using Microsoft.Sharepoint;
string spServerURL = SPWeb.ServerRelativeUrl;
Run Code Online (Sandbox Code Playgroud)

MSDN文档SPWeb.ServerRelativeURL

概述了Sharepoint 2010 14 hive结构.