【发布时间】:2010-12-12 23:03:30
【问题描述】:
我最初的问题here 回答了如何检查列表中是否存在项目,但这不适用于列表中子文件夹中的项目。
无论项目存储在哪个子文件夹中,如何检查项目是否存在?
如果做不到这一点,我如何检查项目是否存在,即使这意味着以某种方式将子文件夹值传递给查询?
以下代码有效,但不会查看子文件夹:
private bool attachmentLinkItemDoesntExist(string attachmentName)
{
XmlDocument doc = new XmlDocument();
doc.LoadXml("<Document><Query><Where><Contains><FieldRef Name=\"Title\" /><Value Type=\"Text\">" + this.downloadedMessageID + "_" + attachmentName + "</Value></Contains></Where></Query><ViewFields /><QueryOptions /></Document>");
XmlNode listQuery = doc.SelectSingleNode("//Query");
XmlNode listViewFields = doc.SelectSingleNode("//ViewFields");
XmlNode listQueryOptions = doc.SelectSingleNode("//QueryOptions");
XmlNode items = this.wsLists.GetListItems(this.AttachmentsListName , string.Empty, listQuery, listViewFields, string.Empty, listQueryOptions, null);
if (items.ChildNodes[1].Attributes["ItemCount"].Value == "0")
{
return true;
}
else
{
return false;
}
}
【问题讨论】:
标签: sharepoint wss