Pages

Monday 23 July 2012

Converting StorageFiles (png) to a Byte[] in order to display as an Image in WinRT (C#)

When you are building Metro Applications it will be very common that your application will have image (.png) files stored in local isolated storage and that you will want to show these images to the users inside your application.  In this post I am going to walk you though how to access these stored files and how to show them inside your XAML application.

Step 1: How to access the Storage File

var packageLocation = Windows.ApplicationModel.Package.Current.InstalledLocation;
var assetsFolder = await packageLocation.GetFolderAsync("Assets");
StorageFile myImage = await assetsFolder.GetFileAsync("myFile.png");
 
// We now have our StorageFile to work with
 
 
 
Read full article here
 
 

No comments:

Post a Comment

Web Informer Button