Hi mates,
how to loop files inside document folder
- string siteUrl = "https://Contoso.sharepoint.com/sites/EagleWipro";
- string clientId = "de356957be31";
- string clientSecret = "SI1UCNW2rrnHoow=";
- using (var clientContext = new OfficeDevPnP.Core.AuthenticationManager().GetAppOnlyAuthenticatedContext(siteUrl, clientId, clientSecret))
- {
- try
- {
- Web oWebsite = clientContext.Web;
- clientContext.Load(oWebsite);
- clientContext.ExecuteQuery();
- List targetlist = oWebsite.Lists.GetByTitle("Documents");
- CamlQuery query = new CamlQuery();
- query.FolderServerRelativeUrl = "/sites/EagleTest/Shared Documents";
- ListItemCollection itemColl = targetlist.GetItems(query);
- clientContext.Load(itemColl);
- clientContext.Load(itemColl, d => d.Include(o => o["DisplayName"], o => o.File));
- clientContext.ExecuteQuery();
- foreach (ListItem listitem in itemColl)
- {
- Console.WriteLine(listitem.displayName);
- }
Here issue is itemColl returning count :0 infact files are there in the Documents folder
how to load files from Share Documents folder
Infact same code i tried with SPO authentication(userName/Password) its working fine, but as per requirement i tried ClientId, ClientSecreatID , but it returns Count 0.
your help would be highly appreciated