Hi everyone... I'd like to let users to choose a background image... so, this is what i've thought:
- User select a photo with a photochoser Task
- the path and the name of the selected photo isa saved in IsolatedStorageSettings
- Everytime the app is launched I read the path/name and show the selected image as background....
if (e.TaskResult == TaskResult.OK)
//Settings.BackgroundPhotoUrl = System.IO.Path.GetFileName(e.OriginalFileName);
Settings.BackgroundPhotoUrl = e.OriginalFileName;
This does not work.. I obtain an exception when i try to open the file: "Operation not permitted on IsolatedStorageFileStream"... Debugging, seems that selected file does not exist!!!! The path is impossible is wrong! But perhaps i need to save the selected image in the Isolated Storage...
using (var store = IsolatedStorageFile.GetUserStoreForApplication())
var fileStream = store.OpenFile(Settings.BackgroundPhotoUrl, FileMode.Open, FileAccess.Read);
So when I choose a photo I run the following method:
Does not work! I obtain the following exception when i try to set the source of the bitmapimage: "Offset and length were out of bounds for the array or count is greater than the number of elements from index to the end of the source collection.
private void SaveToIsolatedStorage(string newPath, Stream choosenPhoto)
var store =
var stream = store.CreateFile(newPath);
BitmapImage i = new BitmapImage();
WriteableBitmap imageToSave = new WriteableBitmap(i);
imageToSave.SaveJpeg(stream,i.PixelWidth, i.PixelHeight, 0, 100);
Can anyone help me plz?