TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Murali Kris
1.5k
254
48.3k
how to loop the files from the documents folder
Jun 30 2020 6:11 AM
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
Reply
Answers (
2
)
How to clear Apex stack bar chart to bind new data
Manage USer Permission in sharepoint using REST API