简体   繁体   English

Windows Phone 8:从Assets文件夹共享图像

[英]Windows Phone 8: Share an Image from Assets folder

I want to use ShareMediaTask to share an images inside my application's Assets folder, here's the code I use: 我想使用ShareMediaTask在应用程序的Assets文件夹内共享图像,这是我使用的代码:

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();
}

But the standard Windows Phone sharing screen never appers. 但是标准的Windows Phone共享屏幕永远不会消失。 It just go back to the page where I came after click the share button. 单击共享按钮后,它就回到我来到的页面。

In debug mode, I am able to see the file.Path is: 在调试模式下,我可以看到该文件。路径为:

C:\Data\Programs\{E6357D2C-2888-448E-8990-4C8D37510514}\Install\Assets\shanghaimetro-1.png

It should be correct path. 它应该是正确的路径。

Is there anything wrong in this code? 这段代码有什么问题吗? How can I make it working? 我该如何运作?

You need to save the photo to the MediaLibrary and then use the GetPath() extension method ( Microsoft.Xna.Framework.Media.PhoneExtensions namespace) to retrieve the path. 您需要将照片保存到MediaLibrary ,然后使用GetPath()扩展方法( Microsoft.Xna.Framework.Media.PhoneExtensions命名空间)来检索路径。 Assign this path to the FilePath property 将此路径分配给FilePath属性

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何从Windows Phone 8.1中的Assets文件夹中获取图像并将其分配给模型的属性 - How to get image from assets folder in windows phone 8.1 and assign it to a model's property 如何在Windows Phone 8.1 RT中将文件从Assets文件夹导出到手机的Documents文件夹? - How to export a file from the Assets folder to the phone's Documents folder in Windows Phone 8.1 RT? 使用JSON显示资产中的图像-Windows Phone 8 - Display images from Assets with JSON - Windows Phone 8 在Windows Phone 8的社交网站上共享图像 - Share image on social networking site in windows phone 8 从文件夹RelativeID获取文件夹 - Windows Phone - Getting Folder from folder RelativeID - Windows Phone 显示本地文件夹中的图像,其中图像名称作为来源从Windows Phone 8应用程序中的sqlite数据库获取 - display image from local folder where image name as source get from sqlite database in windows phone 8 apps 使用Windows Phone SDK V7.1共享图像 - share image using windows phone sdk v7.1 如何在不将图像保存到Windows Phone 8中的库的情况下共享图像? - How can i Share an image without saving it to Gallery in Windows Phone 8? 如何使用XAML和C#从Windows Phone 8中的文件夹创建图库? - How can I create an image gallery from a folder in Windows Phone 8 using XAML and C#? 将图像从Web保存到Windows Phone 8.1 RT C#中的“保存的图片”文件夹 - Saving an image from the web to the Saved Pictures folder in Windows Phone 8.1 RT C#
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM