I am trying to select all PowerPoint files in a list. How do I do that? Up until now I used this:
class UsedIn
{
private static NetworkCredential credential = new NetworkCredential("login", "pwd", "domain");
static String filename = "Engineering_Weekly_Report.pptx";
static void Main(string[] args)
{
try
{
// Creating the Clientcontext
ClientContext clientContext = new ClientContext("https://sharepoint.adress.com/subfolder/");
clientContext.Credentials = credential;
Web oWebsite = clientContext.Web;
// Collect all lists from Sharepoint.
ListCollection collList = oWebsite.Lists;
clientContext.Load(collList);
clientContext.ExecuteQuery();
Console.WriteLine("Connected to Sharepoint.");
// Getting the Presentation.
Console.WriteLine("Working on " + filename + "..");
Guid id = new Guid("CC37C3F4-97D0-4181-87A3-6143DD45004F"); // List ID for the Slide Library.
List sharedDocumentsList = clientContext.Web.Lists.GetById(id);
CamlQuery camlQuery = new CamlQuery();
camlQuery.ViewXml = "<View Scope = 'RecursiveAll'></View>";
ListItemCollection listItems = sharedDocumentsList.GetItems(camlQuery);
clientContext.Credentials = credential;
clientContext.Load(sharedDocumentsList);
clientContext.ExecuteQuery();
clientContext.Credentials = credential;
clientContext.Load(listItems);
clientContext.ExecuteQuery();
Console.WriteLine("Opened Document.");
foreach (var item in listItems)
{
clientContext.Credentials = credential;
FileInformation fileInformation = ClientOM.File.OpenBinaryDirect(clientContext, (string)item["FileRef"]);
using (MemoryStream memoryStream = new MemoryStream())
{
PresentationDocument ppt = PresentationDocument.Open(memoryStream, true);
Console.WriteLine("Found the Document.");
}
}
Console.WriteLine("Done.");
Console.Read();
}
catch (Exception ex) when (ex is ServerException || ex is InvalidCastException || ex is OpenXmlPackageException || ex is WebException)
{
}
}
But now I have to work with a list that is not clean and has some pdfs in it. Is there a way to only select .pptx
with CAML?