Last active
August 29, 2015 14:05
-
-
Save chakkaradeep/9ee19af313dfc8a3bb05 to your computer and use it in GitHub Desktop.
Office 365 API My Files - Get All Files from a Folder
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static async Task<ObservableCollection<MyFile>> GetMyFiles(string strFolderName) | |
{ | |
//MyFile is the business object | |
ObservableCollection<MyFile> myFilesList = new ObservableCollection<MyFile>(); | |
//get the files from the folder | |
var filesResults = await _spFilesClient.Files[strFolderName].ToFolder().Children.ExecuteAsync(); | |
//get the results from current page | |
var files = filesResults.CurrentPage.OfType<Microsoft.Office365.SharePoint.File>().ToList(); | |
//enumerate the results and build the business object | |
foreach (var file in files) | |
{ | |
MyFile myFile = new MyFile(); | |
myFile.Id = file.Id; | |
myFile.Name = file.Name; | |
myFile.ContentStream = await GetFileContent(file.Id); | |
myFilesList.Add(myFile); | |
} | |
//return the business object collection | |
return myFilesList; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment