I have 2 ListItems, each has a DocumentSet with 2 documents each. I'm attempting to download only those Documents attached to the current ListItem.
This is my first time working with documentSets.
This is What I've tried
CamlQuery query = new CamlQuery
{
//<-- Returns only a Single file which is wrong
ViewXml = "<View Scope='RecursiveAll'>" +"<Query>" +"<Where>" +"<Eq>" +"<FieldRef Name='ID'/>" +"<Value Type='Int'>" + Item["ID"] + "</Value>" +"</Eq>" +"</Where>" +"</Query>" +"</View>"
// <--- Returns all 4 files which is wrong
//ViewXml = @"<View Scope='RecursiveAll'>
// <Query>
// <Where>
// <Eq>
// <FieldRef Name='FSObjType' />
// <Value Type='int'>0</Value>
// </Eq>
// </Where>
// </Query>
// </View>"
};
Web web = ctx.Web;
Microsoft.SharePoint.Client.List list = web.Lists.GetByTitle(SharePointConnector.DocumentLibrary);
ListItemCollection items = list.GetItems(query);
ctx.Load(items, collection => collection.Include(i => i.File.ServerRelativeUrl, i => i.File.Name));
try
{
ctx.ExecuteQuery();
}
catch (System.Exception ex)
{
Console.WriteLine(string.Format("SharePoint Communication error - Message: {0}\n", ex.Message));
SharePointConnector.lstExceptions.Add(Utilities.Exception(Service.Type.Sharepoint, ex, null));
Utilities.ShowEXITMessage();
}
return items.Select(i => i.File).ToList();