我正在为 SharePoint 2010 构建一个 Web 部件,以获取所有文档库以及对用户有用的信息。这意味着,用户上传的文档等。我不想显示表单模板、样式库、自定义报告等库...
我只想仅显示包含有用信息的文档库,如共享文档,或者任何其他用户将来创建的,这可能吗?
目前,我的逻辑如下:
SPListCollection docLibraryColl = wb.GetListsOfType(SPBaseType.DocumentLibrary);
Guid docLibFeatId = new Guid("00bfea71-e717-4e80-aa17-d0c71b360101");
foreach (SPList list in docLibraryColl)
{
if (list.TemplateFeatureId == docLibFeatId && !list.Hidden)
{
SPDocumentLibrary doclib = (SPDocumentLibrary)list;
//rest of the logic here...
}
}
我已阅读 此处 Guid 00bfea71-e717-4e80-aa17-d0c71b360101
将仅返回具有 MS 文档库模板的库,但我仍然在其中获取那些不需要的库结果。
I'm building a webpart for SharePoint 2010 to get all the document libraries with usefull info for the user. This means, docs that users uploaded, etc. I don't want to show libraries such as Form Templates, Style Library, Customized Reports, etc...
I just want to show only the document libraries with usefull info, as Shared Documents, or any other users create in the future, is that possible?
Currently, my logic looks like this:
SPListCollection docLibraryColl = wb.GetListsOfType(SPBaseType.DocumentLibrary);
Guid docLibFeatId = new Guid("00bfea71-e717-4e80-aa17-d0c71b360101");
foreach (SPList list in docLibraryColl)
{
if (list.TemplateFeatureId == docLibFeatId && !list.Hidden)
{
SPDocumentLibrary doclib = (SPDocumentLibrary)list;
//rest of the logic here...
}
}
I've read here that Guid 00bfea71-e717-4e80-aa17-d0c71b360101
will return only libraries with MS Document Library template, but I'm still getting those undesired libraries in the results.
发布评论
评论(2)
在
if
中排除您不想要的库有什么问题?您已经选择了
BaseType
DocumentLibrary,因此您只会收到文档库,不幸的是表单模板也是一个 doclib,因此您将始终在您的选择中获得它。What's wrong with excluding the libraries you don't want in your
if
?You are already selecting the
BaseType
DocumentLibrary, so you will only receive document libraries, unfortunately form templates is a doclib too, so you will always get it in your selection.我使用了这段代码:
I used this piece of code: