Quantcast
Channel: Recent Threads — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 204402

How to get Image from directory path in xamarin forms

$
0
0

I want to retrieve image which i have it's path in phone

filepath = "/storage/emulated/0/Android/data/com.CommunicatorEye/files/Pictures/EmployeesCards/IMG_20190131_143513.jpg";

var image = DependencyService.Get<IDependency().RetriveImageFromLocation(filepath);

IDependency.cs

 public interface IDependency
    {
        Task<Image> RetriveImageFromLocation(string location);
    }

Android DependencyImplementation.cs

public async Task<Image> RetriveImageFromLocation(string location)
        {
            Image image = new Image();
            var memoryStream = new MemoryStream();

            using (var source = System.IO.File.OpenRead(location))
            {
                await source.CopyToAsync(memoryStream);
            }

            image.Source = ImageSource.FromStream(() => memoryStream);
            return image;
        }

but it doesn't work for me , any sample ?


Viewing all articles
Browse latest Browse all 204402

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>