Reputation: 73
Currently implementing Code to Access a specific Folder called "Customer" which is inside my Documents Folder in Sharepoint. Whatever I tried it wont work..
var list = await pnpContext.Web.Lists.GetByTitleAsync("Documents",
p => p.RootFolder,
p => p.Items.QueryProperties(p => p.UniqueId, p => p.All, p => p.Title),
p => p.Fields);
var folder = list.Items.AsRequested().FirstOrDefault(p => p.Title == "Customer");
The result of this is that I always get a "null". Hope anyone have ideas to fix it.
Edit: Also tried "GetFolderByServerRelativeUrlAsync" still failed.
string folderUrl = $"{pnpContext.Uri.PathAndQuery}/Documents/Customer";
var folder = await pnpContext.Web.GetFolderByServerRelativeUrlAsync(folderUrl);
Upvotes: 1
Views: 604
Reputation: 338
this works for me
IList list = await _pnpContext.Web.Lists.GetByTitleAsync("Documents");
var subfolder = await list.RootFolder.Folders.FirstOrDefaultAsync(f => f.Title == "Customer");
Upvotes: 0