Save photo in Windows Phone Gallery?

1

I am using the following code to save the image in IsolateStorage:

String tempJPEG = "/Shared/Media/card.jpg";
using (IsolatedStorageFile myIsolatedStorage = IsolatedStorageFile.GetUserStoreForApplication())
{
    if (myIsolatedStorage.FileExists(tempJPEG))
    {
        myIsolatedStorage.DeleteFile(tempJPEG);
    }
    IsolatedStorageFileStream fileStream = myIsolatedStorage.CreateFile(tempJPEG);
    Extensions.SaveJpeg(bmp, fileStream, bmp.PixelWidth, bmp.PixelHeight, 0, 85);
    fileStream.Close();
}

And this code to try to save the image in the gallery:

using (IsolatedStorageFile myIsolatedStorage = IsolatedStorageFile.GetUserStoreForApplication())
{
    using (IsolatedStorageFileStream fileStream = myIsolatedStorage.OpenFile("/Shared/Media/card.jpg", FileMode.Open, FileAccess.ReadWrite))
    {

        MediaLibrary mediaLibrary = new MediaLibrary();
        mediaLibrary.SavePicture("SavedCard.jpg", fileStream);
        fileStream.Close();
    }
}

But when I try to run the app, it closes and Visual gives this error:

I've been trying to solve this problem for days. I found an example, however it uses image of the project itself, soon it is easy, in my case the image is of the project, however it is edited by the user and saved in IsolateStorage ..

    
asked by anonymous 18.07.2015 / 05:23

1 answer

1

This error happens when you do not give the app permission to access the image gallery.

First, go to Propities > WMAppManifest.xml

Ifitisto8.1,youalsohavetoenableitinPackage.appxmanifest

    
23.08.2015 / 02:34