C# Windows Phone 8:共享资产文件夹中的图像

C# Windows Phone 8:共享资产文件夹中的图像,c#,windows-phone-8,windows-phone,C#,Windows Phone 8,Windows Phone,我想使用ShareMediaTask共享应用程序资产文件夹中的图像,下面是我使用的代码: private async void MenuShare_Click(object sender, EventArgs e) { StorageFolder installationFolder = Windows.ApplicationModel.Package.Current.InstalledLocation; StorageFile file = await installation

我想使用ShareMediaTask共享应用程序资产文件夹中的图像,下面是我使用的代码:

private async void MenuShare_Click(object sender, EventArgs e)
{
    StorageFolder installationFolder = Windows.ApplicationModel.Package.Current.InstalledLocation;
    StorageFile file = await installationFolder.GetFileAsync(@"Assets\shanghaimetro-1.png");

    var shareMediaTask = new ShareMediaTask
    {
        FilePath = file.Path
    };
    shareMediaTask.Show();
}
但标准的Windows Phone共享屏幕从未出现过。单击“共享”按钮后,它会返回到我所在的页面

在调试模式下,我可以看到文件。路径为:

C:\Data\Programs\{E6357D2C-2888-448E-8990-4C8D37510514}\Install\Assets\shanghaimetro-1.png
它应该是正确的路径


这个代码有什么错误吗?如何使其工作?

您需要将照片保存到
MediaLibrary
中,然后使用
GetPath()
扩展方法(
Microsoft.Xna.Framework.Media.PhoneExtensions
命名空间)检索路径。将此路径指定给
FilePath
属性