0

I have an issue when converting a string URL to bitmap.

"Cannot convert from Java.IO.FileInputStream to System.IO.Stream"

Is There a solution to fix this? or how can I convert imgUrl to Bitmap so I need to upload it to firebase storage?

 public static Bitmap GetBitmap(string imgUrl) { File imageFile = new File(imgUrl); FileInputStream fs = null; Bitmap bm = null; fs = new FileInputStream(imgUrl); bm = BitmapFactory.DecodeStream(fs); return bm; } 
4
  • 2
    Use a System.IO.FileStream (via File.OpenRead) instead of the Java framework... Commented May 26, 2019 at 17:36
  • I'm using a directory, so it throws exceptions that I don't have enough permissions. What should I do? System.UnauthorizedAccessException: Access to the path "/storage/emulated/0/Pictures/Instagram/IMG_20190226_195851_668.jpg" is denied. This is my code => Bitmap bm = null; FileStream fs = System.IO.File.OpenWrite(imgUrl); bm = BitmapFactory.DecodeStream(fs); Commented May 26, 2019 at 18:53
  • If you are trying to write|read to|from the public Pictures directory (that is outside of your app's sandbox), first you need to add manifest permission, second you need to request runtime permission. There are many SOs about this (i.e. stackoverflow.com/questions/46911486/…) and Xamarin-based blog posts (i.e. devblogs.microsoft.com/xamarin/…), etc... Commented May 26, 2019 at 19:01
  • Possible duplicate of Load image from url to ImageView - C# Commented May 27, 2019 at 6:48

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.