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
var discoveryCapabilitiesResult = await discoveryClient.DiscoverCapabilitiesAsync(); | |
foreach(var serviceCapability in discoveryCapabilitiesResult) | |
{ | |
txtBoxStatus.Text += String.Format(discoveryResultText, | |
serviceCapability.Key, | |
serviceCapability.Value.ServiceEndpointUri.ToString(), | |
serviceCapability.Value.ServiceResourceId).Replace("\n", Environment.NewLine); | |
} |
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
var discoveryClient = new DiscoveryClient(DiscoveryServiceEndpointUri, | |
async () => | |
{ | |
var authResult = await GetAccessTokenAsync(DiscoveryServiceResourceId); | |
userId = authResult.UserInfo.UniqueId; | |
return authResult.AccessToken; | |
}); |
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
async void GetContacts() | |
{ | |
DiscoveryClient discoveryClient = new DiscoveryClient(discoveryServiceEndpointUri, | |
() => | |
{ | |
var authResult = authContext.AcquireTokenSilentSync(discoveryServiceResourceId, ClientId, AadUserInfo.UserId); | |
return authResult.AccessToken; | |
}); |
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 Delete(string strFileId) | |
{ | |
var file = await _spFilesClient.Files.GetById(strFileId).ToFile().ExecuteAsync(); | |
await file.DeleteAsync(); | |
} |
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 UpdateFileContent(string strFileId, Stream stremFileContent) | |
{ | |
var file = (IFileFetcher)(await _spFilesClient.Files.GetById(strFileId).ToFile().ExecuteAsync()); | |
await file.UploadAsync(stremFileContent); | |
} |
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 Update(MyFile myFile, Stream streamFileContent) | |
{ | |
var file = await _spFilesClient.Files.GetById(myFile.Id).ToFile().ExecuteAsync(); | |
file.Name = myFile.Name; | |
await file.UpdateAsync(); | |
} |
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<MyFile> Create(string strFileName, Stream streamFileContent) | |
{ | |
//MyFile is the business object | |
MyFile myFile = null; | |
//add the file to OneDrive | |
//file name will be the full file name along with the extension | |
IFile file = await _spFilesClient.Files.AddAsync(strFileName, true, streamFileContent); | |
if (file != null) |
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<Stream> GetFileContent(string strFileId) | |
{ | |
var file = (IFileFetcher)(await _spFilesClient.Files.GetById(strFileId).ToFile().ExecuteAsync()); | |
var streamFileContent = await file.DownloadAsync(); | |
streamFileContent.Seek(0, System.IO.SeekOrigin.Begin); | |
return streamFileContent; | |
} |
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(); |
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() | |
{ | |
ObservableCollection<MyFile> myFilesList = new ObservableCollection<MyFile>(); | |
var filesResults = await _spFilesClient.Files.ExecuteAsync(); | |
var files = filesResults.CurrentPage.OfType<Microsoft.Office365.SharePoint.File>().ToList(); | |
foreach (var file in files) | |
{ |
NewerOlder