我知道文件夾名稱 我想要在Sharepoint文檔庫中創建的文件夾的ID。 如何編寫CAML查詢來搜索文檔庫中獲取的文件夾,並在此其ID PLZ幫助..Sharepoint文檔庫和CAML
Rushikesh
我知道文件夾名稱 我想要在Sharepoint文檔庫中創建的文件夾的ID。 如何編寫CAML查詢來搜索文檔庫中獲取的文件夾,並在此其ID PLZ幫助..Sharepoint文檔庫和CAML
Rushikesh
SPQuery q = new SPQuery();
q.MeetingInstanceId = -1; //in case your document library is in meeting workspace, query items from all meetings
q.ViewAttributes = "Scope='RecursiveAll'"; //Query all folders (if this is not set, only current folder will be queryied)
q.Query =
<Where>
<And>
<BeginsWith>
<FieldRef Name='ContentTypeId' />
<Value Type='Text'>0x0120</Value>
</BeginsWith>
<Eq>
<FieldRef Name='Title' />
<Value Type='Text'>Folder name</Value>
</Eq>
</And>
</Where>
然後你執行查詢並獲得ID:
SPListItemCollection items = list.GetItems(q);
if (items.Count > 0)
int folderId = items[0].ID
您還可以通過使用SPList.Folders財產
枚舉列表文件夾,我知道這是一個古老的線程,但我想在上面的例子一個SP 2010的環境,它沒有工作,所以我想我會添加我的工作CAML。而不是使用ContentTypeID字段,我只是使用ContentType =文件夾
<Where>
<And>
<Eq>
<FieldRef Name='ContentType'/>
<Value Type='Text'>Folder</Value>
</Eq>
<Eq>
<FieldRef Name="Title"/>
<Value Type='Text'>Folder Name</Value>
</Eq>
</And>
</Where>
如果對ContentType查詢使用BeginsWith運算符,實際上它將返回的不僅僅是文件夾。 RootOfList,討論,摘要任務,文檔集合文件夾,文檔集,系統媒體集合,視頻...以及從文件夾繼承的所有自定義內容類型。 ;) – Panoone