从 OneDrive 下载文件时返回值为 null [英] Returned value is null when downloading a file from OneDrive

查看:51
本文介绍了从 OneDrive 下载文件时返回值为 null的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

正如文档中所说,我尝试下载文件方式:

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.
}

但是 result.File 为空.我认为我的文件路径有问题,如下所示:

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

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

也试过:path = "file.8c8ce076ca27823f.8C8CE076CA27823F!129/content"

怎么了?它是一个 Windows 运行时应用程序,使用 LiveSDK 5.6

推荐答案

要读取文件内容,使用文件 ID +/content 然后访问流.

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

示例:

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;

这篇关于从 OneDrive 下载文件时返回值为 null的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆