1. CAML in Library

a. 查询文档库时,文件的Name属性对应的内部名称是“FileLeafRef”;

b. 需要查询所有内容时(包括文件和文件夹),可使用以下代码(注意此处的scope是RecursiveAll): 

string sQuery = @"
                        
                            
                        
                ";
string sViewFields = @"";
string sViewAttrs = @"Scope=""RecursiveAll""";
uint iRowLimit = 0;
var oQuery = new SPQuery();
oQuery.Query = sQuery;
oQuery.ViewFields = sViewFields;
oQuery.ViewAttributes = sViewAttrs;
oQuery.RowLimit = iRowLimit;
SPListItemCollection collListItems = oList.GetItems(oQuery);


c. 需要查询文件时,可以是使用如下代码(注意此处的scope是Recursive):


string sQuery = @"
                    
                        
                    
                ";
string sViewFields = @"";
string sViewAttrs = @"Scope=""Recursive""";
uint iRowLimit = 0;
var oQuery = new SPQuery();
oQuery.Query = sQuery;
oQuery.ViewFields = sViewFields;
oQuery.ViewAttributes = sViewAttrs;
oQuery.RowLimit = iRowLimit;
SPListItemCollection collListItems = oList.GetItems(oQuery)


d. 如果不加任何scope,那么只能查询到文档库根目录中的内容;