GetThumbnailAsync throw exception'完成此操作所需的数据尚不可用。 (自HRESULT异常:0x8000000A)'自本地OneDrive文件夹中的文件的Fall Creator更新和启用按需同步 [英] GetThumbnailAsync throwing exception 'The data necessary to complete this operation is not yet available. (Exception from HRESULT: 0x8000000A)' since Fall Creator Update for files in a local OneDrive folder and on-demand sync enabled

查看:135
本文介绍了GetThumbnailAsync throw exception'完成此操作所需的数据尚不可用。 (自HRESULT异常:0x8000000A)'自本地OneDrive文件夹中的文件的Fall Creator更新和启用按需同步的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个UWP应用程序并要求创建图像文件缩略图。我为此目的使用StorageFile.GetThumbnailAsync()方法,如下所示实现。用例是用户使用文件选择器选择特定文件夹,并且
应用程序迭代此文件夹中的图像文件。它适用于任何文件夹的Fall Creator更新。自Fall Creator更新以来,我在为任何本地OneDrive文件夹中的图像文件创建缩略图时遇到问题,但是,如果启用了新的按需同步功能,则只需
。实际上,当我尝试调用它时,GetThumbnailAsync()会抛出以下异常:"完成此操作所需的数据尚不可用。 (来自HRESULT的异常:0x8000000A)"。禁用按需同步时,
完全相同的代码运行正常,然后按预期创建缩略图。它也适用于任何其他文件夹。

I am working on an UWP app and require image file thumbnails to be created. I am using the StorageFile.GetThumbnailAsync() method for this purpose, implemented as shown below. The use case is that the user picks a specific folder using a file picker, and the app iterates over the image files in this folder. It worked fine until the Fall Creator update for any folder. Since the Fall Creator update, I am having a problem creating thumbnails for image files located in any local OneDrive folder, however, only if the new on-demand sync feature is enabled. Essentially, GetThumbnailAsync() throws the following exception when I try to invoke it: "The data necessary to complete this operation is not yet available. (Exception from HRESULT: 0x8000000A)". The very same code runs fine when on-demand sync is disabled, thumbnails are then created as expected. It also works fine for any other folder.

public async Task< BitmapImage> ImportFileAsImageItem(StorageFile CurrentFile)
{
try
{
var image = new BitmapImage(){DecodePixelWidth = 250};
StorageItemThumbnail fileThumbnail = await CurrentFile.GetThumbnailAsync(ThumbnailMode.DocumentsView,250,ThumbnailOptions.ResizeThumbnail);
image.SetSource(fileThumbnail);
返回图片
}
catch(Exception ex)
{
System.Diagnostics.Debug.WriteLine(ex.Message);
}
}

public async Task<BitmapImage> ImportFileAsImageItem(StorageFile CurrentFile) { try { var image = new BitmapImage() { DecodePixelWidth = 250 }; StorageItemThumbnail fileThumbnail = await CurrentFile.GetThumbnailAsync(ThumbnailMode.DocumentsView, 250, ThumbnailOptions.ResizeThumbnail); image.SetSource(fileThumbnail); return image } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.Message); } }

找到解决方案的任何提示都是非常感谢。

Any hints to find a solution are highly appreciated.

推荐答案

您好sebsc

>>基本上,当我尝试调用它时,GetThumbnailAsync()会抛出以下异常:"完成此操作所需的数据
尚不可用。 (HRESULT异常:0x8000000A)"。

按需同步功能是秋季创建者更新的新功能。

"当您打开Files On-Demand时,您将在文件资源管理器中看到所有文件并获取有关每个文件的新信息。
在线或在其他设备上创建的新文件显示为仅在线文件,不会占用设备空间。" 这意味着您可以在onedrive中查看文件信息文件夹,但在打开这些文件之前不会下载。

"When you turn on Files On-Demand, you’ll see all your files in File Explorer and get new information about each file. New files created online or on another device appear as online-only files, which don’t take up space on your device."  This means you could see files information in the onedrive folder but you won’t download until you open these files.

您可以在此处获得有关此新功能的更多信息:

了解OneDrive文件点播

在您的场景中,当您选择时首次使用一个文件,它会给你例外,因为这个文件当时没有下载
。但是,如果在下载图像时选择相同的图像,则可以获取缩略图。您可以检查状态图标以查看是否已下载文件。

>>当禁用按需同步时,相同的代码运行正常,然后按预期创建缩略图。 

如果您关闭按需同步,OneDrive会将所有文件下载到您的设备。每个文件都是下载的,然后
不会给出异常。

最好的问候,

Roy


这篇关于GetThumbnailAsync throw exception'完成此操作所需的数据尚不可用。 (自HRESULT异常:0x8000000A)'自本地OneDrive文件夹中的文件的Fall Creator更新和启用按需同步的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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