4

我今天来找你是因为我不知道如何将图像从资产复制到本地存储。我尝试类似的东西:

StorageFile file = await StorageFile.GetFileFromApplicationUriAsync(
    new Uri("appx:///Assets/image.png"));

await file.CopyAsync(ApplicationData.Current.LocalFolder, "image.png");

但它根本不起作用。有谁知道这样做对吗?谢谢你的时间,问候。

4

2 回答 2

9

您的 Uri 方案无效。它应该是ms-appx:,而不是appx:

StorageFile file = await StorageFile.GetFileFromApplicationUriAsync(
    new Uri("ms-appx:///Assets/image.png"));

await file.CopyAsync(ApplicationData.Current.LocalFolder, "image.png");

有关有效的 Uri 方案,请参阅此帖子:Windows 8 应用程序中支持的 URI 方案

于 2013-03-22T11:31:20.487 回答
2

Refer this link

Download an image to local storage in Metro style apps

Also

How ro store image locally once it was downloaded by Image control in Windows 8?

Might be helpful.

于 2013-03-22T09:20:42.507 回答