是否可以从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);
答案 0 :(得分:0)
这将检索列表中文件名为“filename”的所有项目。
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 );