从OneDrive下载文件时,返回值为null

时间:2014-05-16 20:29:23

标签: c# windows-phone-8 windows-runtime windows-store-apps live-sdk

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

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

}
catch
{
    // Handle errors.
}

result.File为空。我认为我的文件路径有问题,就像这样:

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

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

有什么不对? 它是一个Windows运行时应用程序,使用LiveSDK 5.6

1 个答案:

答案 0 :(得分:1)

要阅读文件内容,请使用文件ID + / content,然后访问该流。

示例:

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;