Closed Shyammi closed 6 years ago
Something like this?
let getFiles = (folderUrl) => {
sp.web.getFolderByServerRelativeUrl(folderUrl)
.expand("Folders, Files").get().then(r => {
r.Folders.forEach(item => {
getFiles(item.ServerRelativeUrl);
})
r.Files.forEach(item => {
console.log(item.ServerRelativeUrl);
})
});
}
getFiles("/Style Library");
It worked!!!
Thanks a lot, Tavikukko..
Hi,
I have a project requirement where I need to retrieve files from all folders and sub folders within a document library and display it in a tabular format. I could manage to get files from root level using the following query
$pnp.sp.web.folders.getByName(LibraryName).files.get()..then(function(data){ });
Similarly, I managed to retrieve files present within a folder by passing relative URL, but I'm struggling to retrieve all the files present within folders and subfolders of a document library.
Any help is much appreciated!!!
Thanks, Shyam