Hello,
Welcome to Microsoft Q&A!
It depends on where the image comes from .
- If the image is available on internet , we can just share the link . await Share.RequestAsync(new ShareTextRequest
{
Uri = uri,
Title = "Image Link"
});- If the image is from internal storage , we can share the file according to the path. await Share.RequestAsync(new ShareFileRequest
{
Title = Title,
File = new ShareFile(file)
}); - If the image is from Embedded resource(shared project ) , we can get the stream from the file and save it into file , and then share the file . //read stream from bundle
var assembly = IntrospectionExtensions.GetTypeInfo(typeof(App)).Assembly;
Stream stream = assembly.GetManifestResourceStream("FormsA.dog2.png"); //save data into file
var documentsPath = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
documentsPath = Path.Combine(documentsPath, "Share");
Directory.CreateDirectory(documentsPath); string filePath = Path.Combine(documentsPath, "share.png"); byte[] bArray = new byte[stream.Length];
using (FileStream fs = new FileStream(filePath, FileMode.OpenOrCreate))
{
using (stream)
{
stream.Read(bArray, 0, (int)stream.Length);
}
int length = bArray.Length;
fs.Write(bArray, 0, length);
} //share from file
await Share.RequestAsync(new ShareFileRequest
{
Title = Title,
File = new ShareFile(filePath)
});
- If the image is from internal storage , we can share the file according to the path. await Share.RequestAsync(new ShareFileRequest
Best Regards,
Cole Xia
If the response is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.