我正在尝试通过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()
。
非常感谢任何指导。
答案 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();