Is it possible to use ShareMediaTask along with the image save on the isolated storage. I tried to implement the same by applying the below given code. But when i run the co
Sorry, currently ShareMediaTask only supports items in the Media Library either in the Camera Roll folder of the Saved Pictures folder. That's done due to security reasons. If for example you use ShareMediaTask and share with another app, that app should never have access to your app's IsoStore. For that reason, ShareMediaTask doesn't currently support IsoStore file paths.
Here's an end-to-end code sample of how to save an image into the MediaLibrary Saved Pictures and use the ShareMediaTask @ http://www.reflectionit.nl/Blog/PermaLink620a4c87-a4af-4007-b4bc-81d851b11658.aspx
private void ButtonShare_Click(object sender, RoutedEventArgs e) {
var bmp = new WriteableBitmap(this.ContentPanel, null);
var width = (int)bmp.PixelWidth;
var height = (int)bmp.PixelHeight;
using (var ms = new MemoryStream(width * height * 4)) {
bmp.SaveJpeg(ms, width, height, 0, 100);
ms.Seek(0, SeekOrigin.Begin);
var lib = new MediaLibrary();
var picture = lib.SavePicture(string.Format("test.jpg"), ms);
var task = new ShareMediaTask();
task.FilePath = picture.GetPath();
task.Show();
}
}
You can also save pictures into the Camera Roll folder and use the ShareMediaTask using the MediaLibrary.SavePictureToCameraRoll() extension method.
I have done with the following code :
BitmapImage bi = new BitmapImage(new Uri(string.Format("Data/{0}/{1}", Category, img), UriKind.Relative)));
bi.CreateOptions = BitmapCreateOptions.BackgroundCreation;
bi.ImageOpened += (s1, e1) =>
{
var bmp = new WriteableBitmap(bi);
var width = (int)bmp.PixelWidth;
var height = (int)bmp.PixelHeight;
using (var ms = new MemoryStream(width * height * 4))
{
bmp.SaveJpeg(ms, width, height, 0, 100);
ms.Seek(0, SeekOrigin.Begin);
var lib = new MediaLibrary();
Picture picture = null;
try
{
picture = lib.SavePicture(string.Format("test.jpg"), ms);
}
catch (Exception ex)
{
Debug.WriteLine(ex.Message);
}
var task = new ShareMediaTask();
task.FilePath = picture.GetPath();
task.Show();
}
};