Xamarin Forms : byte[] to image , save the iamge in device and open it again

56 views Asked by At
byte[] imageAsBytes = (byte[].obj.RawData);
var stream = new MemoryStream(imageAsBytes);
image = ImageSource.FromStream(() => stream);

string filename = "myimage.png";
string root = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
string filePath = Path.Combine(root, filename);
using (FileStream fileStream = new FileStream(filePath, FileMode.Create))
{
     await fileStream.WriteAsync(imageData, 0, imageData.Length);
}
var filepath = await SaveImageAsync(imageAsBytes, filename);

 if (!string.IsNullOrEmpty(filepath))
 {
     Debug.WriteLine($"File path is{filepath}");
     Launcher.OpenAsync(new OpenFileRequest
     {
         File = new ReadOnlyFile(filepath)
     });
 }

in this i can able to open the image but it is not visible in the device failed to open the image

0

There are 0 answers