0

我使用 Live SDK 5.6,我正在尝试从 OneDrive 下载文件。使用CreateBackgroundDownloadAsync (innerItem.ID + "/Content"),为什么结果文件为空?

foreach (var innerItem in resultItems.data)
{
    if (innerItem.name == "MoneyNote.db")
    {
        LiveDownloadOperation operation = await liveConnectClient.CreateBackgroundDownloadAsync(innerItem.id + "/Content");
        //LiveDownloadOperationResult downloadResult = await operation.StartAsync();
        var downloadResult = await operation.StartAsync();
        if (downloadResult.File != null)
        {
            StorageFile downFile = await ApplicationData.Current.LocalFolder.GetFileAsync("MoneyNote.db");
            await downloadResult.File.MoveAndReplaceAsync(downFile);
            messagePrint(true);
        }
        else
        {
            messagePrint(false);
        }
    }
}
4

1 回答 1

0

我认为问题可能是,因为您正在创建后台下载(不是在后台下载),然后您开始此下载操作,但文件需要时间下载。在这种情况下,可能更容易下载这样的文件:

foreach (var innerItem in resultItems.data)
{
    if (innerItem.name == "MoneyNote.db")
    {
        StorageFile downFile = await ApplicationData.Current.LocalFolder.CreateFileAsync("MoneyNote.db", CreationCollisionOption.ReplaceExisting);
        var result = await liveConnectClient.BackgroundDownloadAsync(innerItem.id + "/content", downFile);
        messagePrint(true);
    }
}
于 2015-01-12T05:59:31.093 回答