使用SharedMediaTask GetPath()进行图像共享时出错

时间:2013-11-12 13:16:27

标签: c# windows-phone-7 windows-phone-8 media-library

我正在尝试通过SharedMediaTask与媒体库分享照片,但我收到来自GetPath()的错误。错误说:

  

错误1' Microsoft.Xna.Framework.Media.MediaLibrary'不包含' GetPath'的定义和最好的扩展方法重载...

以下是我通过SharedMediaTask进行照片分享的代码:

//Open Saved image from isolated storage
IsolatedStorageFile Store = IsolatedStorageFile.GetUserStoreForApplication();
IsolatedStorageFileStream toShare = new IsolatedStorageFileStream(filePath1, FileMode.Open, FileAccess.ReadWrite, Store);

//Save image to media library
MediaLibrary library = new MediaLibrary();
library.SavePicture("Memefy_Photo", toShare);

//Open ShareMediaTask
var task = new ShareMediaTask();
task.FilePath = library.GetPath(); //<----THIS is where the error appears :(
task.Show();

此外,我已根据我的研究使用此using Microsoft.Xna.Framework.Media.PhoneExtensions;根据需要启用GetPath()

非常感谢任何指导。

1 个答案:

答案 0 :(得分:1)

GetPath在图片上定义,而不是在媒体库上定义。

//Save image to media library
MediaLibrary library = new MediaLibrary();
var picture = library.SavePicture("Memefy_Photo", toShare);

//Open ShareMediaTask
var task = new ShareMediaTask();
task.FilePath = picture.GetPath();
task.Show();