I want to use ShareMediaTask to share an images inside my application's Assets folder, here's the code I use:
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. 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. Assign this path to the FilePath
property
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.