【发布时间】:2012-10-11 15:19:15
【问题描述】:
我正在尝试从 SharePoint 2010 管理中心网站获取场功能列表。我遇到的问题是我只成功撤回了 Site 功能。以下代码是我目前正在使用的代码:
foreach (SPFeature feature in SPAdministrationWebApplication.Local.Features)
{
string featureName = feature.Definition.DisplayName;
if (featureName != null)
{
XElement newItem = new XElement("Item", featureName);
infoTree.Add(newItem);
}
}
我也试过使用SPFarm.Local.FeatureDefinitions,如下:
foreach (SPFeatureDefinition feature in SPFarm.Local.FeatureDefinitions)
{
string featureName = feature.DisplayName;
if (featureName != null)
{
XElement newItem = new XElement("Item", featureName);
infoTree.Add(newItem);
}
但无济于事。我正在接近的下一条途径是使用SPFeatureCollection。有没有更好的方法可以解决这个问题?基本上我只是在寻找一些线索,因为我还没有从SPFeatureCollection 得到任何东西。
编辑 我一直在玩弄
SPFeatureCollection featureCollect = SPContext.Current.Site.Features
但到目前为止,我遇到了 SPContext 返回 null 的问题。
【问题讨论】:
-
我已经编辑了你的标题。请参阅“Should questions include “tags” in their titles?”,其中的共识是“不,他们不应该”。
-
抱歉,我通常用它来启动 Google 查询。非故意违规
-
没问题。 Stack Overflow 将第一个标签放入标题中。
标签: c# sharepoint sharepoint-2010