AymenDaoudi
AymenDaoudi

Reputation: 8309

UWP : Can't retrieve files correctly from LocalFolder

During the OnLaunched of my application I create a file like this :

await ApplicationData.Current.LocalFolder.CreateFileAsync(Keys.AdContentBig);

Later on, I write some bytes into that file (the file is an image)

The file is well written, and well present :

enter image description here

After that I want to retrieve that URI of that file using the ms-appdata: schema to show it, what I do is this :

var f = await ApplicationData.Current.LocalFolder.GetFileAsync(Keys.AdContentBig);
uriDestination = new Uri("ms-appdata:///local/LocalState/" + f.Name, UriKind.RelativeOrAbsolute);
imageSource = new BitmapImage(uriDestination );

and on XAML, a typical :

<Image Source="{x:Bind Vm.imageSource, Mode=OneWay}"/>

The compiler doesn't complain about the existence of the file, nor does it break or something, nothing happens and the image is not shown, surely I'm doing somehing wrong with "ms-appdata:///local/LocalState/", if I am please correct me, or tell me what else I'm missing.

Upvotes: 0

Views: 1477

Answers (1)

sibbl
sibbl

Reputation: 3229

Try it with only "ms-appdata:///local/" + f.Name.

ms-appdata:///local/my_folder
equals
C:\Data\Users\username\AppData\{guid}\LocalState‌​\my_folder

Upvotes: 6

Related Questions