I'm using the SharePoint Managed Client Object Model API to retrieve files from SharePoint to my console app which is written in C#. My code (abbreviated here) looks something like this:
ClientContext clientContext = GetClientContext(sitePath);
Web rootWeb = clientContext.Web;
var files= rootWeb.GetFolderByServerRelativeUrl(relativeURL).Files;
clientContext.Load(files);
clientContext.ExecuteQuery();
// FileCollection files has no results
The returned FileCollection (files) has no results even though the folder specified (in the relativeURL) actually has a couple of files in it. When I run the bit of code below, the Folder object's ItemCount property is 2.
ClientContext clientContext = GetClientContext(sitePath);
Web rootWeb = clientContext.Web;
var folder = rootWeb.GetFolderByServerRelativeUrl(relativeURL);
clientContext.Load(folder);
clientContext.ExecuteQuery();
// folder.ItemCount == 2
I can't figure out why I can't seem to get the files. All the permissions seem OK. Are there any other gotcha's that exist in the API?