Here is my code:
StringBuilder sb = new StringBuilder();
sb.AppendLine(@"<Where><Lt>");
sb.AppendLine(@"<FieldRef Name=""FileRef"" /><Value Type=""Text"">momo.txt</Value>");
sb.AppendLine(@"</Lt></Where>");
XmlDocument xmlDoc = new System.Xml.XmlDocument();
XmlNode ndQuery = xmlDoc.CreateNode(XmlNodeType.Element, "Query", "");
ndQuery.InnerXml = sb.ToString();
XmlNode resultsElement1 = listsProxy.GetListItems("Documents", "", ndQuery,
null, null, null, "");
But it returns all the Documents any Idea what I am doing wrong here?
Thanks.
The
FileReffields contains the server-relative URL to the document, something like this “/Subsite/Lists/ListName/DocumentName“. If you provide only the file name (e.g.mono.txt), neitherLtorEqshould work.To fix the problem, you might try:
Eqwith the server-relative URL instead of file name.<Contains>operator (CAML does not have <EndsWith>operator).Then looping over the returned results, and remove items which does not end with “
/mono.txt“.In addition, if you care about document name without extension, you could you
BaseNameinstead ofFileReffield.