Answered by:
Load a bitmap

Question
-
guys
The following loads the picture "001.jpg" from the Pictures Library into an image called roompic
var files = await KnownFolders.PicturesLibrary.GetFileAsync("001.jpg");
var fileStream = await files.OpenAsync(Windows.Storage.FileAccessMode.Read);
BitmapImage img = new BitmapImage();
img.SetSource(fileStream);
roompic.Source = img;This works fine as long as the file is in the root of the pictures library
I have a folder in there call Images
How do I load from a sub directory in the pictures library
any help appreciated
Mark
Sunday, November 17, 2013 6:48 PM
Answers
-
KnownFolders
.PicturesLibrary.GetFolderAsync()
Microsoft Certified Solutions Developer - Windows Store Apps Using C#
- Marked as answer by wambaugh1 Sunday, November 17, 2013 8:34 PM
Sunday, November 17, 2013 8:03 PM
All replies
-
var folder = await KnownFolders.PicturesLibrary.GetFolder("a folder")\
var files = await folder .PicturesLibrary.GetFileAsync("001.jpg");
Microsoft Certified Solutions Developer - Windows Store Apps Using C#
Sunday, November 17, 2013 7:20 PM -
Hi
I tried the following:
var folder = await KnownFolders.PicturesLibrary.GetFolder("Images");
var files = await folder .GetFileAsync("001.jpg");
var fileStream = await files.OpenAsync(Windows.Storage.FileAccessMode.Read);
BitmapImage img = new BitmapImage();
img.SetSource(fileStream);
roompic.Source = img;it has one error
the word GETFOLDER has a squiggly line uinder it and it is saying
Error 1 'Windows.Storage.StorageFolder' does not contain a definition for 'GetFolder' and no extension method 'GetFolder' accepting a first argument of type 'Windows.Storage.StorageFolder' could be found (are you missing a using directive or an assembly reference?)
i have declared the following
using Windows.Storage;
using Windows.Storage.AccessCache;
using Windows.Storage.Streams;any idea?
Mark
Sunday, November 17, 2013 7:45 PM -
KnownFolders
.PicturesLibrary.GetFolderAsync()
Microsoft Certified Solutions Developer - Windows Store Apps Using C#
- Marked as answer by wambaugh1 Sunday, November 17, 2013 8:34 PM
Sunday, November 17, 2013 8:03 PM -
hi
I tried that and it says it cannot find the file yet there is a directory and a file as specified
is there a way of say showing the path in a textblock so I can see where it is looking
Mark
Sunday, November 17, 2013 8:10 PM -
hi
I got it to show my the path and I think the problem is its not adding the final "\"
the path of folder showing in the textbox is is "C:\Users\Mark\Pictures\Images"
How do I add the "\" to the end
Mark
Sunday, November 17, 2013 8:18 PM -
you sure the folder exists?
Microsoft Certified Solutions Developer - Windows Store Apps Using C#
Sunday, November 17, 2013 8:26 PM -
yes im looking at it now
it has the 001.jpg file inside it
mark
Sunday, November 17, 2013 8:30 PM -
Hi
I cracked it
It wasnt the folder that was wrong it was the filename
I had renamed the file and inadvertently called it 001.jpg.jpg
removing the 2nd .jpg made it work
thank you for your help
Mark
Sunday, November 17, 2013 8:33 PM