是否可以从 SharePoint 获取特定文件,而不是在 onlce 获取所有文件?
在下面的查询中,当我queryNode
为空时,我正在获取所有文件,但是当queryNode
注释查询时,我没有获得任何文件。
这里缺少什么?
XmlDocument xmlDoc = new XmlDocument();
XmlNode queryNode = xmlDoc.AppendChild(xmlDoc.CreateNode(XmlNodeType.Element, "Query", ""));
//queryNode.InnerXml = "<Where>" +
// " <Eq>" +
// " <FieldRef Name='FileLeafRef'></FieldRef>" +
// " <Value Type='File'>" + SomeFileName + "</Value>" +
// " </Eq>" +
// "</Where>";
queryNode.InnerText = "";
XmlDocument xmlDoc1 = new XmlDocument();
XmlNode viewNode = xmlDoc.AppendChild(xmlDoc.CreateNode(XmlNodeType.Element, "ViewFields", ""));
viewNode.InnerXml = "";
XmlDocument xmlDoc2 = new XmlDocument();
XmlNode optionsNode = xmlDoc.AppendChild(xmlDoc.CreateNode(XmlNodeType.Element, "QueryOptions", ""));
optionsNode.InnerText = "";
XmlNode nodeListItems = wsList.GetListItems("Documents",
"",
queryNode,
viewNode,
"1",
optionsNode,
null);
这将检索文件名仅为"文件名"的列表中的所有项目。
var list = web.Lists["ListTitle"];
var fileQuery = new SPQuery();
fileQuery .ViewAttributes = "Scope="Recursive"";
string strQuery = "<Where>" +
"<Eq>" +
"<FieldRef Name="FileLeafRef"/>" +
"<Value Type="Text">" + fileName + "</Value>" +
"</Eq>" +
"</Where>";
fileQuery .Query = strQuery ;
SPListItemCollection collListItems = list.GetItems(fileQuery );