Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/280.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/294.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 使用SharedMediaTask GetPath()进行图像共享时出错_C#_Windows Phone 7_Windows Phone 8_Media Library - Fatal编程技术网

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

C# 使用SharedMediaTask GetPath()进行图像共享时出错,c#,windows-phone-7,windows-phone-8,media-library,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.GetUserSt

我正试图通过
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();
//从独立存储中打开保存的映像
IsolatedStorageFile Store=IsolatedStorageFile.GetUserStoreForApplication();
IsolatedStorageFileStream toShare=新的IsolatedStorageFileStream(filePath1,FileMode.Open,FileAccess.ReadWrite,Store);
//将图像保存到媒体库
MediaLibrary=新的MediaLibrary();
保存图片(“Memefy_Photo”,toShare);
//打开ShareMediaTask
var task=新的ShareMediaTask();

task.FilePath=library.GetPath()//
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();

以上答案是正确的。但是您必须添加一个名称空间。。。使用Microsoft.Xna.Framework.Media.PhoneExtensions;添加此命名空间后,可以使用picture.GetPath()方法。