I am trying to move a part of code written in Java (Android) to C# (Mono for android) and I am stuck at finding a way to do this. The part of the code in Java is as follows:
private Bitmap decodeFile(File f){
try {
BitmapFactory.Options o = new BitmapFactory.Options();
o.inJustDecodeBounds = true;
BitmapFactory.decodeStream(new FileInputStream(f), null, o);
...
} catch(FileNotFoundException ex){
}
Precisely, converting from Java.IO.File to System.IO.Stream as required by the first parameter of DecodeStream is my problem. How should this statement be rewritten?
I usually use the static System.File methods to obtain the corresponding FileStream:
In your case, you should get rid of the “File” class that you have in java: File is a static class in .NET. Can you pass the path directly (as a String) to your decodeFile function?