I’m writing a Windows 8 app in C# using visual studio 2012 Ultimate.
When trying to load an image resource stored in the assets folder however I’m am always getting the exception FileNotFoundException “The system cannot find the file specified. (Exception from HRESULT: 0x80070002)” even though the file exists in the /Assets folder of the project.
private async void LoadImage(string ImageFile)
{
Uri imageUri = new Uri("ms-appx:///Assets/Apple.jpg");
StorageFile pictureFile = await StorageFile.GetFileFromApplicationUriAsync(imageUri);
BitmapImage bitmap = new BitmapImage();
bitmap.SetSource(await pictureFile.OpenAsync(FileAccessMode.Read));
imgPicture.Source = bitmap;
}
Can anyone see what is wrong?
thanks.
Nevermind, I’ve found the solution. It seems that you can only access files that have been added to the project. This makes sense however.