Recently I was trying to share an image from my app using contract. It is always good to provide as much as possible sharing ways, so target app could choose the best one. But to do it image should be loaded to StorageFile^ format first. There is how to do this:
Uri^ uri = ref new Uri("ms-appx:///Assets/Logo.png"); create_task(StorageFile::GetFileFromApplicationUriAsync(uri)).then([](task<StorageFile^> t) { auto storageFile = t.get(); });
First of all, all files in metro app accessed this way: 'ms-appx:///'
should be wrote before any path. This tells to program that we are using applications own storage.
I belive that this code work in the same fassion as event-handlers. Firstly this code runs
create_task(StorageFile::GetFileFromApplicationUriAsync(uri))
and then it is finished, this code runs
auto storageFile = t.get();
I still need to spend some time learning asynchronous C++