问题
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