Returned value is null when downloading a file from OneDrive

大憨熊 提交于 2019-12-25 02:29:11

问题


As it is said in the documentation, I try to download a file way:

try
{
    LiveDownloadOperation operation = await connectClient.CreateBackgroundDownloadAsync(filePath);
    var result = await operation.StartAsync();
    var file = result.File; // It is null

}
catch
{
    // Handle errors.
}

But result.File is null. I think something is wrong with my file path, which is like this:

path = "file.8c8ce076ca27823f.8C8CE076CA27823F!129"

also tried: path = "file.8c8ce076ca27823f.8C8CE076CA27823F!129/content"

what is the wrong? it is a windows runtime app, using LiveSDK 5.6


回答1:


To read the file content, use the file ID + /content and then access the stream.

example:

LiveConnectClient liveClient = new LiveConnectClient(liveSession);
LiveDownloadOperation operation = 
         await liveClient.CreateBackgroundDownloadAsync(fileId + "/content");
var operationResult = await operation.StartAsync();

var fileContent = 
         await CustomMethod(await operationResult.GetRandomAccessStreamAsync());

return fileContent;


来源:https://stackoverflow.com/questions/23704052/returned-value-is-null-when-downloading-a-file-from-onedrive

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!