Winrt c # copy image from asset to localstorage

I come to you today because I do not know how to copy an image from an asset to localstorage. I am trying something like:

StorageFile file = await StorageFile.GetFileFromApplicationUriAsync( new Uri("appx:///Assets/image.png")); await file.CopyAsync(ApplicationData.Current.LocalFolder, "image.png"); 

But this does not work at all. Anyone have an idea to do it right? Thanks for your time, best regards.

+4
source share
2 answers

Your Uri scheme is invalid. It should be ms-appx: and not appx: ::

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

See this post for valid Uri schemes: URI schemes supported in Windows 8 applications

+7
source

All Articles